From 8b29c959fbdb0ae3235a5c6a15632927fc83b36b Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Fri, 4 Apr 2025 17:42:35 +0000 Subject: [PATCH] Split up neonvim configuration into lua files rather than lua heredoc --- vim/.config/nvim/init.vim | 60 +------------ .../nvim/lua/user/indentblanklines.lua | 8 ++ vim/.config/nvim/lua/user/lspconfig.lua | 85 +++++++++++++++++++ 3 files changed, 95 insertions(+), 58 deletions(-) create mode 100644 vim/.config/nvim/lua/user/indentblanklines.lua create mode 100644 vim/.config/nvim/lua/user/lspconfig.lua diff --git a/vim/.config/nvim/init.vim b/vim/.config/nvim/init.vim index 82134b8..7ca9aa7 100644 --- a/vim/.config/nvim/init.vim +++ b/vim/.config/nvim/init.vim @@ -5,65 +5,9 @@ source ~/.vimrc lua <lua vim.lsp.buf.hover()') - - -- Jump to the definition - bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') - - -- Jump to declaration - bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') - - -- Lists all the implementations for the symbol under the cursor - bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') - - -- Jumps to the definition of the type symbol - bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') - - -- Lists all the references - bufmap('n', 'gr', 'lua vim.lsp.buf.references()') - - -- Displays a function's signature information - bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') - - -- Renames all references to the symbol under the cursor - bufmap('n', '', 'lua vim.lsp.buf.rename()') - - -- Selects a code action available at the current cursor position - bufmap('n', '', 'lua vim.lsp.buf.code_action()') - - -- Show diagnostics in a floating window - bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') - - -- Move to the previous diagnostic - bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') - - -- Move to the next diagnostic - bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') - end -}) EOF nnoremap ib IBLToggle diff --git a/vim/.config/nvim/lua/user/indentblanklines.lua b/vim/.config/nvim/lua/user/indentblanklines.lua new file mode 100644 index 0000000..38c1997 --- /dev/null +++ b/vim/.config/nvim/lua/user/indentblanklines.lua @@ -0,0 +1,8 @@ +-- Configure the 'indent-blankline' plugin +-- Look at configuring this for rainbow blocks at some point +require('ibl').setup{ + enabled = false, + indent = { + char = '|' + } +} diff --git a/vim/.config/nvim/lua/user/lspconfig.lua b/vim/.config/nvim/lua/user/lspconfig.lua new file mode 100644 index 0000000..3895db2 --- /dev/null +++ b/vim/.config/nvim/lua/user/lspconfig.lua @@ -0,0 +1,85 @@ +print('User LSP Configuration loaded') +local lsp = require('lspconfig') + +-- Configure LuaLS for lua +lsp.lua_ls.setup{ + on_init = function(client) + local path = client.workspace_folders[1].name + if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then + client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + } + }) + + client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) + end + return true + end +} + +lsp.pylsp.setup{} +lsp.solargraph.setup{} + + +-- Setup LSP bindings +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function() + local bufmap = function(mode, lhs, rhs) + local opts = {buffer = true} + vim.keymap.set(mode, lhs, rhs, opts) + end + + -- Displays hover information about the symbol under the cursor + bufmap('n', 'K', 'lua vim.lsp.buf.hover()') + + -- Jump to the definition + bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') + + -- Jump to declaration + bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') + + -- Lists all the implementations for the symbol under the cursor + bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') + + -- Jumps to the definition of the type symbol + bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') + + -- Lists all the references + bufmap('n', 'gr', 'lua vim.lsp.buf.references()') + + -- Displays a function's signature information + bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') + + -- Renames all references to the symbol under the cursor + bufmap('n', '', 'lua vim.lsp.buf.rename()') + + -- Selects a code action available at the current cursor position + bufmap('n', '', 'lua vim.lsp.buf.code_action()') + + -- Show diagnostics in a floating window + bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') + + -- Move to the previous diagnostic + bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') + + -- Move to the next diagnostic + bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') + end +})