From cb7e7a5ea4a066b827e4972b1edf93ca3d6bc03a Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Fri, 26 Sep 2025 16:07:46 +0200 Subject: [PATCH] Refactor LSP config into separate modules --- .config/nvim/after/plugin/lsp.lua | 73 ++------------------ .config/nvim/after/plugin/neotest.lua | 35 ---------- .config/nvim/lazy-lock.json | 16 ++--- .config/nvim/lsp/expert.lua | 5 ++ .config/nvim/lsp/gopls.lua | 14 ++++ .config/nvim/lsp/lua_ls.lua | 13 ++++ .config/nvim/lua/halfdan/colorscheme.lua | 2 +- .config/nvim/lua/halfdan/plugins/neorg.lua | 38 ++++++++-- .config/nvim/lua/halfdan/plugins/neotest.lua | 12 ++++ 9 files changed, 88 insertions(+), 120 deletions(-) delete mode 100644 .config/nvim/after/plugin/neotest.lua create mode 100644 .config/nvim/lsp/expert.lua create mode 100644 .config/nvim/lsp/gopls.lua create mode 100644 .config/nvim/lsp/lua_ls.lua diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 10c5d51..4093af8 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -79,11 +79,11 @@ end, { noremap = true, silent = true }) -- See `:help vim.diagnostic.*` for documentation on any of the below functions vim.keymap.set('n', 'e', vim.diagnostic.open_float) vim.keymap.set('n', ']d', function() - vim.diagnostic.goto_next() + vim.diagnostic.jump({count=1, float=true}) end, { desc = "Go to next diagnostic" }) vim.keymap.set('n', '[d', function() - vim.diagnostic.goto_prev() + vim.diagnostic.jump({count=-1, float=true}) end, { desc = "Go to previous diagnostic" }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) @@ -117,73 +117,8 @@ vim.api.nvim_create_autocmd('LspAttach', { end, opts) end, }) - -vim.lsp.config("lua_ls", { - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using - version = "LuaJIT", - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry = { - -- Do not send telemetry data containing a randomized but unique identifier - enable = false, - }, - }, - }, -}) - - --- Enable it -local neodev = require("neodev") - --- must run before enabling lua_ls -neodev.setup({}) - -vim.lsp.config("lua_ls", { - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - diagnostics = { globals = { "vim" } }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { enable = false }, - }, - }, -}) - -vim.lsp.config('gopls', { - cmd = { "gopls" }, - filetypes = { "go", "gomod", "gowork", "gotmpl" }, - root_markers = { "go.work", "go.mod", ".git" }, - settings = { - gopls = { - analyses = { - unusedparams = true, - shadow = true, - }, - staticcheck = true, - }, - }, -}) - vim.lsp.enable 'lua_ls' vim.lsp.enable 'gopls' - -vim.lsp.config('expert', { - cmd = { 'expert' }, - root_markers = { 'mix.exs', '.git' }, - filetypes = { 'elixir', 'eelixir', 'heex' }, -}) - vim.lsp.enable 'expert' +vim.lsp.enable 'ruff' +vim.lsp.enable 'pyright' diff --git a/.config/nvim/after/plugin/neotest.lua b/.config/nvim/after/plugin/neotest.lua deleted file mode 100644 index 29e8bd8..0000000 --- a/.config/nvim/after/plugin/neotest.lua +++ /dev/null @@ -1,35 +0,0 @@ -if vim.g.vscode then - return -end - -local nnoremap = require('halfdan.keymap').nnoremap -local neotest = require('neotest') -local neotest_ns = vim.api.nvim_create_namespace("neotest") - -vim.diagnostic.config({ - virtual_text = { - format = function(diagnostic) - local message = - diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") - return message - end, - }, -}, neotest_ns) - - - -nnoremap("nt", function() - neotest.run.run() -end) - -nnoremap("nf", function() - neotest.run.run(vim.fn.expand("%")) -end) - -nnoremap("nd", function() - neotest.run.run({ strategy = "dap" }) -end) - -nnoremap("ns", function() - neotest.summary.toggle() -end) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 5fef603..1f3bf0d 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,9 +1,8 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "FTerm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" }, - "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "catppuccin": { "branch": "main", "commit": "5af9374957a65be8770696da295dc9016b96f241" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "editorconfig-vim": { "branch": "master", "commit": "6a58b7c11f79c0e1d0f20533b3f42f2a11490cf8" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, @@ -11,6 +10,7 @@ "git-blame.nvim": { "branch": "master", "commit": "9874ec1ec8bc53beb33b7cd82c092b85271a578b" }, "gruvbox-baby": { "branch": "main", "commit": "bd52e62d8134647090108189e69c8b3cd18bdbbf" }, "hardtime.nvim": { "branch": "main", "commit": "b4e431934af1fe224a3a801f632c008278cb7628" }, + "kanagawa.nvim": { "branch": "master", "commit": "debe91547d7fb1eef34ce26a5106f277fbfdd109" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, "lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" }, @@ -18,21 +18,21 @@ "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "ed057048a281b418d5318dd5153f9486daa517a3" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, - "neogit": { "branch": "master", "commit": "704ed34e957c8702df994bdcc8404e134d1e8212" }, + "neogit": { "branch": "master", "commit": "add70101fab5913cad33ab2f84f1a6ee092e7220" }, "neorg": { "branch": "main", "commit": "e206c9642f4a115cd836e76c98ef785623d335bc" }, + "neorg-interim-ls": { "branch": "main", "commit": "52bdf8a8cd246a9205756449776aa057bd593d61" }, "neorg-telescope": { "branch": "main", "commit": "7fb6ca6a632c3c095601d379a664c0c1f802dc6c" }, "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, "neotest-elixir": { "branch": "master", "commit": "a242aebeaa6997c1c149138ff77f6cacbe33b6fc" }, - "neotest-golang": { "branch": "main", "commit": "f5bd0488ced4ec266917f7b85f9e896436ab6d3a" }, + "neotest-golang": { "branch": "main", "commit": "8a4a1dee307eafe553241f8b5f3337151678394e" }, "neotest-rust": { "branch": "main", "commit": "2c9941d4a358839918fac21d20fc8fef0e1ad05f" }, - "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-dap": { "branch": "master", "commit": "7367cec8e8f7a0b1e4566af9a7ef5959d11206a7" }, "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, - "nvim-lspconfig": { "branch": "master", "commit": "aafecf5b8bc0a768f1a97e3a6d5441e64dee79f9" }, + "nvim-lspconfig": { "branch": "master", "commit": "336b388c272555d2ae94627a50df4c2f89a5e257" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-treesitter": { "branch": "main", "commit": "5a70b1eb8cbdf6c7f0a59dfb7356ad198421b620" }, @@ -40,7 +40,6 @@ "outline.nvim": { "branch": "main", "commit": "6b62f73a6bf317531d15a7ae1b724e85485d8148" }, "pathlib.nvim": { "branch": "main", "commit": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "rose-pine": { "branch": "main", "commit": "72a04c4065345b51b56aed4859ea1d884f734097" }, "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, "rustaceanvim": { "branch": "master", "commit": "12504405821c05874d2d1f6b5ec919f9808e2c99" }, @@ -58,6 +57,5 @@ "vim-highlightedyank": { "branch": "master", "commit": "285a61425e79742997bbde76a91be6189bc988fb" }, "vim-projectionist": { "branch": "master", "commit": "5ff7bf79a6ef741036d2038a226bcb5f8b1cd296" }, "vim-sneak": { "branch": "master", "commit": "18b1faf020e6a66c1ce09b3ff5e6b6feb182973b" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-test": { "branch": "master", "commit": "5ee3c0b3734eab612b9f70bbc8a4f69f17f8e8ef" } + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" } } diff --git a/.config/nvim/lsp/expert.lua b/.config/nvim/lsp/expert.lua new file mode 100644 index 0000000..6a507a4 --- /dev/null +++ b/.config/nvim/lsp/expert.lua @@ -0,0 +1,5 @@ +return { + cmd = { 'expert' }, + root_markers = { 'mix.exs', '.git' }, + filetypes = { 'elixir', 'eelixir', 'heex' }, +} diff --git a/.config/nvim/lsp/gopls.lua b/.config/nvim/lsp/gopls.lua new file mode 100644 index 0000000..7e9e79d --- /dev/null +++ b/.config/nvim/lsp/gopls.lua @@ -0,0 +1,14 @@ +return { + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_markers = { "go.work", "go.mod", ".git" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + }, + staticcheck = true, + }, + }, +} diff --git a/.config/nvim/lsp/lua_ls.lua b/.config/nvim/lsp/lua_ls.lua new file mode 100644 index 0000000..e3bd0ac --- /dev/null +++ b/.config/nvim/lsp/lua_ls.lua @@ -0,0 +1,13 @@ +return { + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + diagnostics = { globals = { "vim" } }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { enable = false }, + }, + }, +} diff --git a/.config/nvim/lua/halfdan/colorscheme.lua b/.config/nvim/lua/halfdan/colorscheme.lua index 87e79e8..c013c1b 100644 --- a/.config/nvim/lua/halfdan/colorscheme.lua +++ b/.config/nvim/lua/halfdan/colorscheme.lua @@ -1,2 +1,2 @@ vim.g.nvcode_termcolors = 256 -vim.cmd.colorscheme("gruvbox-baby") +vim.cmd.colorscheme("kanagawa-wave") diff --git a/.config/nvim/lua/halfdan/plugins/neorg.lua b/.config/nvim/lua/halfdan/plugins/neorg.lua index 390c565..6d392b8 100644 --- a/.config/nvim/lua/halfdan/plugins/neorg.lua +++ b/.config/nvim/lua/halfdan/plugins/neorg.lua @@ -16,11 +16,9 @@ return { index = "index.norg", } }, - -- ["core.completion"] = { - -- config = { - -- engine = "nvim-cmp", - -- }, - -- }, + ["core.completion"] = { + config = { engine = { module_name = "external.lsp-completion" } }, + }, ["core.concealer"] = {}, ["core.journal"] = { config = { @@ -28,9 +26,37 @@ return { }, }, ["core.integrations.telescope"] = {}, + ["external.interim-ls"] = { + config = { + -- default config shown + completion_provider = { + -- Enable or disable the completion provider + enable = true, + + -- Show file contents as documentation when you complete a file name + documentation = true, + + -- Try to complete categories provided by Neorg Query. Requires `benlubas/neorg-query` + categories = false, + + -- suggest heading completions from the given file for `{@x|}` where `|` is your cursor + -- and `x` is an alphanumeric character. `{@name}` expands to `[name]{:$/people:# name}` + people = { + enable = false, + + -- path to the file you're like to use with the `{@x` syntax, relative to the + -- workspace root, without the `.norg` at the end. + -- ie. `folder/people` results in searching `$/folder/people.norg` for headings. + -- Note that this will change with your workspace, so it fails silently if the file + -- doesn't exist + path = "people", + } + } + } + }, } }) end, }, - { 'nvim-neorg/neorg-telescope' }, + { 'nvim-neorg/neorg-telescope' , 'benlubas/neorg-interim-ls' }, } diff --git a/.config/nvim/lua/halfdan/plugins/neotest.lua b/.config/nvim/lua/halfdan/plugins/neotest.lua index 63ffb3e..c4feaa6 100644 --- a/.config/nvim/lua/halfdan/plugins/neotest.lua +++ b/.config/nvim/lua/halfdan/plugins/neotest.lua @@ -23,6 +23,18 @@ return { require("neotest-golang") }, }) + + local neotest_ns = vim.api.nvim_create_namespace("neotest") + + vim.diagnostic.config({ + virtual_text = { + format = function(diagnostic) + local message = + diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") + return message + end, + }, + }, neotest_ns) end }, }