Refactor LSP config into separate modules

This commit is contained in:
Fabian Becker
2025-09-26 16:07:46 +02:00
parent bb9e97a6ba
commit cb7e7a5ea4
9 changed files with 88 additions and 120 deletions

View File

@@ -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', '<space>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', '<space>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'

View File

@@ -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("<leader>nt", function()
neotest.run.run()
end)
nnoremap("<leader>nf", function()
neotest.run.run(vim.fn.expand("%"))
end)
nnoremap("<leader>nd", function()
neotest.run.run({ strategy = "dap" })
end)
nnoremap("<leader>ns", function()
neotest.summary.toggle()
end)