lsp fixes and tweaks

main
Mathias Rothenhaeusler 2025-11-23 12:17:56 +01:00
parent a660f0c788
commit 8f4d2e287e
2 changed files with 12 additions and 21 deletions

View File

@ -75,25 +75,12 @@ require('lazy').setup({
-- Detect tabstop and shiftwidth automatically -- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth', 'tpope/vim-sleuth',
-- NOTE: This is where your plugins related to LSP can be installed. -- seems i need this regardless
-- The configuration is done below. Search for lspconfig to find it below. 'neovim/nvim-lspconfig',
{ {
-- LSP Configuration & Plugins 'williamboman/mason.nvim', config = true
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true },
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
-- 'folke/neodev.nvim',
},
}, },
'williamboman/mason-lspconfig.nvim',
{ {
-- Autocompletion -- Autocompletion
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',

View File

@ -55,7 +55,10 @@ local on_attach = function(_, bufnr)
keymap.set("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts) keymap.set("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap.set("n", "<leader>l", smart_format, opts) -- keymap.set("n", "<leader>l", smart_format, opts)
keymap.set("n", "<leader>l", function()
vim.lsp.buf.format()
end, { desc = "Format code function" })
keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
keymap.set( keymap.set(
"n", "n",
@ -123,7 +126,7 @@ setup_server("rust_analyzer", {
-- PHP LSPs -- PHP LSPs
local util = vim.lsp.util local util = vim.lsp.util
root_dir = function(fname) local root_dir = function(fname)
return util.root_pattern("composer.json", ".git")(fname) return util.root_pattern("composer.json", ".git")(fname)
or util.path.dirname(fname) or util.path.dirname(fname)
end end
@ -141,12 +144,13 @@ setup_server("phpactor", {
}, },
}) })
vim.lsp.config("lua_ls", { setup_server("lua_ls", {
filetypes = { "lua" }, filetypes = { "lua" },
settings = { settings = {
Lua = { Lua = {
diagnostics = { diagnostics = {
globals = { "vim" } } globals = { "vim" } },
format = { enable = true },
} }
} }
}) })