Dotfiles_nvim/lua/editor/language_server.lua

119 lines
3.2 KiB
Lua
Raw Normal View History

2024-07-02 21:52:43 +00:00
local TOOLCHAIN = require('util.toolchain')
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.lsp_requriemts,
})
end,
},
{
'neovim/nvim-lspconfig',
lazy = false,
config = function()
-- Setup --
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig')
for _, setup in ipairs(TOOLCHAIN.lsp_setups) do
setup(lspconfig, capabilities)
end
-- Keybinding --
vim.keymap.set(
'n',
'<leader>cd',
vim.lsp.buf.hover,
{ desc = 'Show Code Definition' }
)
vim.keymap.set(
'n',
'<leader>gd',
vim.lsp.buf.definition,
{ desc = 'Go to Definition' }
)
vim.keymap.set(
'n',
'<leader>gr',
vim.lsp.buf.references,
{ desc = 'Go to References' }
)
vim.keymap.set(
'n',
'<leader>ca',
vim.lsp.buf.code_action,
{ desc = 'Do Code Actions' }
)
end,
},
{
'nvimtools/none-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvimtools/none-ls-extras.nvim',
},
config = function()
-- Setup --
local null_ls = require('null-ls')
local null_ls_sources = {}
for _, setup_function in ipairs(TOOLCHAIN.null_ls) do
local conf = setup_function(null_ls)
if #conf ~= 0 then
for _, _conf in pairs(conf) do
table.insert(null_ls_sources, _conf)
end
end
end
null_ls.setup({
sources = null_ls_sources,
})
-- Keybinding --
vim.keymap.set(
'n',
'<leader>fc',
vim.lsp.buf.format,
{ desc = 'Format Code' }
)
end,
},
{
'nvimdev/lspsaga.nvim',
after = 'nvim-lspconfig',
dependencies = {
'nvim-treesitter/nvim-treesitter',
'nvim-tree/nvim-web-devicons',
},
config = function()
require('lspsaga').setup({})
-- Keybinding --
vim.keymap.set(
'n',
'<leader>cr',
':Lspsaga rename<CR>',
{ desc = 'Rename Variable' }
)
vim.keymap.set(
'n',
'<leader>cp',
':Lspsaga peek_definition<CR>',
{ desc = 'Peek Code Definition' }
)
end,
},
}