From 11c68f37433b7bc40f9d626775ee72dda23541ec Mon Sep 17 00:00:00 2001 From: FaultyBranches Date: Wed, 31 Dec 2025 16:45:29 -0600 Subject: [PATCH] fix: Moving the LSP configs out of the Mason file, using the new vim.lsp.config way of configuring LSPs, adding the 'after' config directory for LSP specific configs that override/extend those in the 'lsp' dir and fit with the new configuration way of NVIM 0.11+, moving shortcuts to lspconfig instead of Mason, removing the rename custom function in telescope and using the LSP based function. --- deploy.sh | 1 + nvim/after/lsp/cfn-lint.lua | 0 nvim/after/lsp/gdscript.lua | 5 ++ nvim/after/lsp/lua_ls.lua | 11 +++ nvim/after/lsp/marksman.lua | 3 + nvim/after/lsp/pylsp.lua | 21 +++++ nvim/after/lsp/rust_analyzer.lua | 21 +++++ nvim/lua/plugins.lua | 1 + nvim/lua/plugins/lspconfig.lua | 45 +++++++++- nvim/lua/plugins/mason.lua | 143 +++---------------------------- nvim/lua/plugins/telescope.lua | 51 ++--------- 11 files changed, 123 insertions(+), 179 deletions(-) create mode 100644 nvim/after/lsp/cfn-lint.lua create mode 100644 nvim/after/lsp/gdscript.lua create mode 100644 nvim/after/lsp/lua_ls.lua create mode 100644 nvim/after/lsp/marksman.lua create mode 100644 nvim/after/lsp/pylsp.lua create mode 100644 nvim/after/lsp/rust_analyzer.lua diff --git a/deploy.sh b/deploy.sh index 5e26979..fc4de77 100755 --- a/deploy.sh +++ b/deploy.sh @@ -10,6 +10,7 @@ declare -A configs=( ["fb-custom.zsh-theme"]="$HOME/.oh-my-zsh/custom/themes" ["nvim/init.lua"]="$HOME/.config/nvim/init.lua" ["nvim/lua"]="$HOME/.config/nvim/" + ["nvim/after"]="$HOME/.config/nvim/" ["nvim/snippets"]="$HOME/.config/nvim/" ["tmux.conf"]="$HOME/.tmux.conf" ["wezterm.lua"]="$HOME/.config/wezterm/wezterm.lua" diff --git a/nvim/after/lsp/cfn-lint.lua b/nvim/after/lsp/cfn-lint.lua new file mode 100644 index 0000000..e69de29 diff --git a/nvim/after/lsp/gdscript.lua b/nvim/after/lsp/gdscript.lua new file mode 100644 index 0000000..a7695ba --- /dev/null +++ b/nvim/after/lsp/gdscript.lua @@ -0,0 +1,5 @@ +return { + flags = { + debounce_text_changes = 100, + } +} diff --git a/nvim/after/lsp/lua_ls.lua b/nvim/after/lsp/lua_ls.lua new file mode 100644 index 0000000..cba01ed --- /dev/null +++ b/nvim/after/lsp/lua_ls.lua @@ -0,0 +1,11 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = { + 'vim' + } + } + } + } +} diff --git a/nvim/after/lsp/marksman.lua b/nvim/after/lsp/marksman.lua new file mode 100644 index 0000000..5bb1183 --- /dev/null +++ b/nvim/after/lsp/marksman.lua @@ -0,0 +1,3 @@ +return { + filetypes = { 'md', 'markdown', 'telekasten' } +} diff --git a/nvim/after/lsp/pylsp.lua b/nvim/after/lsp/pylsp.lua new file mode 100644 index 0000000..cca0eaa --- /dev/null +++ b/nvim/after/lsp/pylsp.lua @@ -0,0 +1,21 @@ +return { + settings = { + pylsp = { + plugins = { + pycodestyle = { + enabled = false, + ignore = { + 'E501' + }, + maxLineLength = 120, + }, + pylint = { + enabled = true, + args = { + '--disable=line-too-long' + }, + } + } + } + } +} diff --git a/nvim/after/lsp/rust_analyzer.lua b/nvim/after/lsp/rust_analyzer.lua new file mode 100644 index 0000000..3c6b814 --- /dev/null +++ b/nvim/after/lsp/rust_analyzer.lua @@ -0,0 +1,21 @@ +return { + settings = { + ['rust_analyzer'] = { + check = { + command = 'clippy', + extraArgs = { + '--', + '-D clippy::all', + '-W clippy::pedantic', + '-W clippy::restriction' + }, + }, + diagnostics = { + enable = true, + experimental = { + enable = true, + } + } + } + } +} diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 3db1cc5..4be595d 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -14,6 +14,7 @@ end vim.opt.rtp:prepend(lazypath) require('lazy').setup({ + require('plugins.lspconfig'), -- LSP configuration require('plugins.mason'), -- LSP and DAP manager require('plugins.gruvbox'), -- Colorscheme require('plugins.comment'), -- Simple language specific commenting shortcuts diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 39f8bba..6c94600 100644 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -1,4 +1,47 @@ return { 'neovim/nvim-lspconfig', - lazy = false, + -- lazy = false, + config = function () + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + + -- All functions and keymaps contained here are universal to LSPs + local on_attach = function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Keyboard Mappings + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', '', vim.diagnostic.goto_prev, bufopts) + vim.keymap.set('n', '', vim.diagnostic.goto_next, bufopts) + -- vim.keymap.set('n', 'gl', vim.diagnostic.open_float, bufopts) + vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', 'gs', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + end + + -- Kick the logging to debug level + -- vim.lsp.set_log_level("debug") + + vim.diagnostic.config ({ + virtual_text = { + source = 'always', + }, + severity_sort = true, + float = { + source = 'always' + } + }) + + vim.lsp.config('*', { + capabilities = capabilities, + on_attach = on_attach, + }) + end } diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index 7b22493..d8313cd 100644 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -3,149 +3,28 @@ return { config = function() require('mason').setup() - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - - -- All functions and keymaps contained here are universal to LSPs - local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Keyboard Mappings - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', '', vim.diagnostic.goto_prev, bufopts) - vim.keymap.set('n', '', vim.diagnostic.goto_next, bufopts) - -- vim.keymap.set('n', 'gl', vim.diagnostic.open_float, bufopts) - vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', 'gs', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) - end - require('mason-lspconfig').setup { automatic_enable = true, - automatic_installation = true, ensure_installed = { - 'ansiblels', - 'arduino_language_server', - 'bashls', + -- Currently having issues with including some of the LSPs, even though they match the names in Mason + 'ansiblels', -- Ansible + 'arduino_language_server', -- Arduino specific C + 'bashls', -- Bash + -- 'cfn-lint', -- Cloudformation for AWS 'clangd', -- C/C++ + -- 'gdscript', -- Godot script -- 'hadolint', -- Dockerfile linting 'intelephense', -- PHP - 'lua_ls', + 'lua_ls', -- Lua 'marksman', -- markdown - 'pylsp', - 'rust_analyzer', - -- 'ts_ls', -- Typscript - 'yamlls', + 'pylsp', -- Python + 'rust_analyzer', -- Rust + 'ts_ls', -- Typscript + 'yamlls', -- YAML } } - - vim.diagnostic.config ({ - virtual_text = { - source = "always", - }, - severity_sort = true, - float = { - source = "always" - }, - }) - - -- Kick the logging to debug level - -- vim.lsp.set_log_level("debug") - - vim.lsp.config('gdscript', { - capabilities = capabilities, - on_attach = on_attach, - flags = { - debounce_text_changes = 100, - } - }) - - vim.lsp.config('lua_ls', { - capabilities = capabilities, - on_attach = on_attach, - settings = { - Lua = { - diagnostics = { - globals = { - 'vim' - } - } - } - } - }) - - vim.lsp.config('pylsp', { - capabilities = capabilities, - on_attach = on_attach, - settings = { - pylsp = { - plugins = { - pycodestyle = { - enabled = false, - ignore = { - 'E501' -- Ignore line length pep8 warnings - }, - maxLineLength = 120, - }, - pylint = { - enabled = true, - args = { - '--disable=line-too-long' - }, - } - } - } - } - }) - - vim.lsp.config("rust_analyzer", { - capabilities = capabilities, - on_attach = on_attach, - settings = { - ['rust_analyzer'] = { - check = { - command = 'clippy', - extraArgs = { - '--', - '-D clippy::all', - '-W clippy::pedantic', - '-W clippy::restriction' - }, - }, - diagnostics = { - enable = true, - experimental = { - enable = true, - } - } - } - } - }) - - vim.lsp.config("clangd", { - capabilities = capabilities, - on_attach = on_attach, - }) - - vim.lsp.config("marksman", { - capabilities = capabilities, - on_attach = on_attach, - filetypes = { 'md', 'markdown', 'telekasten' } - }) - - vim.lsp.config("*", { - capabilities = capabilities, - on_attach = on_attach, - }) end, dependencies = { - 'neovim/nvim-lspconfig', 'mason-org/mason-lspconfig.nvim', }, lazy = false, diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 0aeabb7..e745a16 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -6,29 +6,6 @@ return { local action_state = require('telescope.actions.state') local fb_actions = telescope.extensions.file_browser.actions - local custom_actions = {} - - function custom_actions.grep_multi_select(prompt_bufnr) - local function get_table_size(t) - local count = 0 - for _ in pairs(t) do - count = count + 1 - end - return count - end - - local picker = action_state.get_current_picker(prompt_bufnr) - local num_selections = get_table_size(picker:get_multi_selection()) - - if num_selections > 1 then - actions.send_selected_to_qflist(prompt_bufnr) - actions.open_qflist() - print(action_state.get_current_picker(prompt_bufnr)) - else - actions.file_edit(prompt_bufnr) - end - end - opts.defaults = { file_ignore_patterns = { '.png$', @@ -39,10 +16,12 @@ return { '.webp$', '.uproject$', '-workspace$', + '.git/', + '.node_modules/', 'node_modules', }, - layout_config = { prompt_position = 'top' }, - layout_strategy = 'horizontal', + layout_config = { prompt_position = 'bottom' }, + layout_strategy = 'vertical', mappings = { i = { [''] = actions.close, @@ -57,20 +36,12 @@ return { opts.pickers = { diagnostics = { - theme = 'ivy', + -- theme = 'ivy', initial_mode = 'normal', layout_config = { preview_cutoff = 9999, }, }, - grep_string = { - initial_mode = 'normal', - mappings = { - ['n'] = { - [''] = custom_actions.grep_multi_select, - }, - }, - }, } opts.extensions = { @@ -101,12 +72,6 @@ return { require('telescope.builtin').find_files({ no_ignore = false, hidden = true, - file_ignore_patterns = { - '.git/', - '.node_modules/', - '.webp', - '.png', - }, }) end, }, @@ -158,12 +123,6 @@ return { require('telescope.builtin').lsp_dynamic_workspace_symbols() end }, - { - 'rn', - function() - require('telescope.builtin').grep_string({ search = vim.fn.expand('') }) - end - }, { ';e', function()