84 lines
3.1 KiB
Lua
84 lines
3.1 KiB
Lua
return {
|
|
-- Main LSP Configuration
|
|
'neovim/nvim-lspconfig',
|
|
dependencies = {
|
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
|
-- Mason must be loaded before its dependents so we need to set it up here.
|
|
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
|
{ 'mason-org/mason.nvim', opts = {} },
|
|
'mason-org/mason-lspconfig.nvim',
|
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
|
|
|
-- Useful status updates for LSP.
|
|
{ 'j-hui/fidget.nvim', opts = {} },
|
|
|
|
-- Allows extra capabilities provided by blink.cmp
|
|
'saghen/blink.cmp',
|
|
},
|
|
config = function()
|
|
|
|
-- Autocommand to define keymaps when a buffer attaches to lsp server
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
|
|
callback = function(event)
|
|
local map = function(keys, func, desc, mode)
|
|
mode = mode or 'n'
|
|
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
|
end
|
|
|
|
-- Rename the variable under your cursor.
|
|
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
|
|
|
|
-- Find references for the word under your cursor.
|
|
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
|
|
|
-- Jump to the implementation of the word under your cursor.
|
|
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
|
|
|
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
|
-- For example, in C this would take you to the header.
|
|
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
|
|
|
-- Fuzzy find all the symbols in your current document.
|
|
-- Symbols are things like variables, functions, types, etc.
|
|
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
|
|
|
|
-- Fuzzy find all the symbols in your current workspace.
|
|
-- Similar to document symbols, except searches over your entire project.
|
|
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
|
|
|
|
-- Jump to the type of the word under your cursor.
|
|
-- Useful when you're not sure what type a variable is and you want to see
|
|
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definiton')
|
|
|
|
-- predefine client supports method
|
|
-- leaving it here in case I want to use it
|
|
---@param client vim.lsp.Client
|
|
---@param method vim.lsp.protocol.Method
|
|
---@param bufnr? integer some lsp support methods only in specific files
|
|
---@return boolean
|
|
local function client_supports_method(client, method, bufnr)
|
|
return client:supports_method(method, bufnr)
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- Diagnostic Options
|
|
vim.diagnostic.config {
|
|
severity_sort = true,
|
|
float = { border = 'rounded', source = 'if_many' },
|
|
underline = { severity = vim.diagnostic.severity.ERROR },
|
|
}
|
|
|
|
require('mason-tool-installer').setup {
|
|
ensure_installed = {
|
|
'lua-language-server',
|
|
'python-lsp-server',
|
|
'stylua',
|
|
}
|
|
}
|
|
|
|
require("mason-lspconfig").setup()
|
|
end
|
|
}
|