From: Lukas Krickl Date: Sun, 28 Dec 2025 07:28:14 +0000 (+0100) Subject: init: moved lua config to lua file X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a2aab51582232189b2f9f763ff49b7273ecf7e22;p=dotfiles%2F.git init: moved lua config to lua file the init.vim file should now be vim compatible --- diff --git a/nvim/init.vim b/nvim/init.vim index b130ef9..8629408 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -89,53 +89,7 @@ hi Pmenu ctermbg=Blue guibg=Blue hi PmenuSel ctermbg=Gray guibg=Gray " Nvim specific! -" Simple LSP setup using nvim-lspconfig -" Simple Treesitter setup - -lua << EOF --- lsp config -local lspconfig = require('lspconfig') --- lspconfig.clangd.setup {} -lspconfig.rust_analyzer.setup {} - - -vim.keymap.set('n', 'e', vim.diagnostic.open_float) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist) - -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - - local opts = { buffer = ev.buf } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'fc', function() - vim.lsp.buf.format { async = true } - end, opts) - end, -}) - --- tresitter requires nvim-treesitter to be installed --- local ts_parser = vim.fn.expand("$HOME/.config/nvim-treesitter/") --- vim.opt.runtimepath:append(ts_parser) --- --- require'nvim-treesitter.configs'.setup { --- highlight = { --- enable = false, --- }, --- parser_install_dir = ts_parser, --- } - -EOF +if has('nvim') + lua require('init') +endif diff --git a/nvim/lua/init.lua b/nvim/lua/init.lua new file mode 100644 index 0000000..cd958c5 --- /dev/null +++ b/nvim/lua/init.lua @@ -0,0 +1,49 @@ +-- Nvim specific! +-- Simple LSP setup using nvim-lspconfig +-- Simple Treesitter setup + +-- lsp config +local lspconfig = require('lspconfig') +-- lspconfig.clangd.setup {} +lspconfig.rust_analyzer.setup {} + + +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'fc', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) + +-- tresitter requires nvim-treesitter to be installed +-- local ts_parser = vim.fn.expand("$HOME/.config/nvim-treesitter/") +-- vim.opt.runtimepath:append(ts_parser) +-- +-- require'nvim-treesitter.configs'.setup { +-- highlight = { +-- enable = false, +-- }, +-- parser_install_dir = ts_parser, +-- } + +