remember to enable lsp

This commit is contained in:
2025-11-19 13:13:50 +01:00
parent c80db2417e
commit 883c4cabb0

View File

@@ -16,17 +16,18 @@ require("fidget").setup({
require('mason').setup({}) require('mason').setup({})
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
ensure_installed = {'bashls', 'clangd', 'marksman', 'pylsp', 'ruff', 'texlab'}, ensure_installed = { 'bashls', 'clangd', 'lua_ls', 'marksman', 'pylsp', 'ruff', 'texlab' },
automatic_enable = false, automatic_enable = false,
}) })
require('mason-nvim-dap').setup({ require('mason-nvim-dap').setup({
ensure_installed = {'bash', 'cppdbg', 'python'}, ensure_installed = { 'bash', 'cppdbg', 'python' },
}) })
require('dap-python').setup("python") require('dap-python').setup("python")
local servers = { local servers = {
bashls = {}, bashls = {},
clangd = {}, clangd = {},
lua_ls = {},
marksman = {}, marksman = {},
pylsp = { pylsp = {
settings = { settings = {
@@ -96,7 +97,7 @@ local servers = {
}, },
forwardSearch = { forwardSearch = {
executable = "zathura", executable = "zathura",
args = { "--synctex-forward", "%l:1:%f", "%p"} args = { "--synctex-forward", "%l:1:%f", "%p" }
}, },
}, },
}, },
@@ -124,13 +125,15 @@ local on_attach = function(_client, buffer_number)
-- Use Prettier to format TS/JS if it's available -- Use Prettier to format TS/JS if it's available
return format_client.name ~= "tsserver" or not null_ls.is_registered("prettier") return format_client.name ~= "tsserver" or not null_ls.is_registered("prettier")
end, end,
async = false,
timeout_ms = 10000,
}) })
end, { desc = "LSP: Format current buffer with LSP" }) end, { desc = "LSP: Format current buffer with LSP" })
end end
-- Iterate over our servers and set them up -- Iterate over our servers and set them up
for name, config in pairs(servers) do for name, config in pairs(servers) do
vim.lsp.config(name,{ vim.lsp.config(name, {
capabilities = default_capabilities, capabilities = default_capabilities,
filetypes = config.filetypes, filetypes = config.filetypes,
handlers = vim.tbl_deep_extend("force", {}, default_handlers, config.handlers or {}), handlers = vim.tbl_deep_extend("force", {}, default_handlers, config.handlers or {}),
@@ -138,6 +141,7 @@ for name, config in pairs(servers) do
settings = config.settings, settings = config.settings,
init_options = config.init_options, init_options = config.init_options,
}) })
vim.lsp.enable(name)
end end
vim.diagnostic.config({ vim.diagnostic.config({
@@ -156,7 +160,7 @@ vim.diagnostic.config({
}) })
-- Autoformat on save -- Autoformat on save
local fmt_group = vim.api.nvim_create_augroup('autoformat_cmds', {clear = true}) local fmt_group = vim.api.nvim_create_augroup('autoformat_cmds', { clear = true })
local function setup_autoformat(event) local function setup_autoformat(event)
local id = vim.tbl_get(event, 'data', 'client_id') local id = vim.tbl_get(event, 'data', 'client_id')
@@ -165,7 +169,7 @@ local function setup_autoformat(event)
return return
end end
vim.api.nvim_clear_autocmds({group = fmt_group, buffer = event.buf}) vim.api.nvim_clear_autocmds({ group = fmt_group, buffer = event.buf })
local buf_format = function(e) local buf_format = function(e)
vim.lsp.buf.format({ vim.lsp.buf.format({
@@ -198,6 +202,6 @@ vim.api.nvim_create_autocmd('LspAttach', {
return return
end end
vim.lsp.inlay_hint.enable(true, {bufnr = event.buf}) vim.lsp.inlay_hint.enable(true, { bufnr = event.buf })
end, end,
}) })