1
0
Fork 1
Dotfiles_nvim/lua/editor/language_server.lua
2024-11-23 17:55:23 +01:00

114 lines
3.3 KiB
Lua

local TOOLCHAIN = require('toolchain')
local K = require('core.keymap')
return {
{
'williamboman/mason.nvim',
lazy = false,
config = function() require('mason').setup() end,
},
{
'williamboman/mason-lspconfig.nvim',
lazy = false,
opts = {
auto_install = true,
},
config = function()
require('mason-lspconfig').setup({
ensure_installed = TOOLCHAIN.get_lsp_autoinstalls(),
})
end,
},
{
'neovim/nvim-lspconfig',
lazy = false,
config = function()
-- Setup --
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig')
TOOLCHAIN.setup_lsps(lspconfig, capabilities)
-- Keybinding --
vim.keymap.set(
K.CODE.SHOW_DEFINITION.mode,
K.CODE.SHOW_DEFINITION.shortcut,
vim.lsp.buf.hover,
{ desc = K.CODE.SHOW_DEFINITION.description }
)
vim.keymap.set(
K.CODE.GOTO_DEFINITION.mode,
K.CODE.GOTO_DEFINITION.shortcut,
vim.lsp.buf.definition,
{ desc = K.CODE.GOTO_DEFINITION.description }
)
vim.keymap.set(
K.CODE.GOTO_REFERENCES.mode,
K.CODE.GOTO_REFERENCES.shortcut,
vim.lsp.buf.references,
{ desc = K.CODE.GOTO_REFERENCES.description }
)
vim.keymap.set(
K.CODE.ACTIONS.mode,
K.CODE.ACTIONS.shortcut,
vim.lsp.buf.code_action,
{ desc = K.CODE.ACTIONS.description }
)
end,
},
{
'nvimtools/none-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvimtools/none-ls-extras.nvim',
},
config = function()
-- Setup --
local null_ls = require('null-ls')
null_ls.setup({
sources = TOOLCHAIN.get_null_ls_source(null_ls),
})
-- Keybinding --
vim.keymap.set(
K.CODE.FORMAT.mode,
K.CODE.FORMAT.shortcut,
vim.lsp.buf.format,
{ desc = K.CODE.FORMAT.description }
)
end,
},
{
'nvimdev/lspsaga.nvim',
after = 'nvim-lspconfig',
dependencies = {
'nvim-treesitter/nvim-treesitter',
'nvim-tree/nvim-web-devicons',
},
config = function()
require('lspsaga').setup({
symbol_in_winbar = {
enable = false,
},
lightbulb = {
enable = false,
},
})
-- Keybinding --
vim.keymap.set(
K.CODE.RENAME.mode,
K.CODE.RENAME.shortcut,
':Lspsaga rename<CR>',
{ desc = K.CODE.RENAME.description }
)
vim.keymap.set(
K.CODE.PEEK_DEFINITION.mode,
K.CODE.PEEK_DEFINITION.shortcut,
':Lspsaga peek_definition<CR>',
{ desc = K.CODE.PEEK_DEFINITION.description }
)
end,
},
}