111 lines
3.8 KiB
Lua
111 lines
3.8 KiB
Lua
return {
|
|
'neovim/nvim-lspconfig',
|
|
dependencies = {
|
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
|
'williamboman/mason.nvim',
|
|
'williamboman/mason-lspconfig.nvim',
|
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
|
'saghen/blink.cmp',
|
|
|
|
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
|
|
-- used for completion, annotations and signatures of Neovim apis
|
|
{ 'folke/lazydev.nvim', opts = {} },
|
|
|
|
-- Useful status updates for LSP.
|
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
{ 'j-hui/fidget.nvim', opts = {} },
|
|
},
|
|
config = function()
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
|
|
callback = function(event)
|
|
-- Automatically highlight copies of the hovered word and then clear on cursor move
|
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
if client and client.server_capabilities.documentHighlightProvider then
|
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
|
buffer = event.buf,
|
|
callback = vim.lsp.buf.document_highlight,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
|
buffer = event.buf,
|
|
callback = vim.lsp.buf.clear_references,
|
|
})
|
|
end
|
|
end,
|
|
})
|
|
|
|
local servers = {
|
|
clangd = {},
|
|
-- gopls = {},
|
|
-- pyright = {},
|
|
rust_analyzer = {},
|
|
powershell_es = {},
|
|
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
|
--
|
|
-- Some languages (like typescript) have entire language plugins that can be useful:
|
|
-- https://github.com/pmizio/typescript-tools.nvim
|
|
--
|
|
-- But for many setups, the LSP (`tsserver`) will work just fine
|
|
-- tsserver = {},
|
|
--
|
|
lua_ls = {
|
|
-- cmd = {...},
|
|
-- filetypes = { ...},
|
|
-- capabilities = {},
|
|
settings = {
|
|
Lua = {
|
|
completion = {
|
|
callSnippet = 'Replace',
|
|
},
|
|
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
|
diagnostics = { disable = { 'missing-fields' } },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
require('mason').setup()
|
|
local ensure_installed = vim.tbl_keys(servers or {})
|
|
vim.list_extend(ensure_installed, {
|
|
'stylua', -- Used to format Lua code
|
|
})
|
|
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
|
|
|
require('mason-lspconfig').setup {
|
|
handlers = {
|
|
function(server_name)
|
|
local server = servers[server_name] or {}
|
|
server.capabilities = require('blink.cmp').get_lsp_capabilities(server.capabilities)
|
|
require('lspconfig')[server_name].setup(server)
|
|
end,
|
|
|
|
powershell_es = function()
|
|
local lspconfig = require 'lspconfig'
|
|
lspconfig.powershell_es.setup {
|
|
init_options = { enableProfileLoading = false },
|
|
filetypes = { 'ps1' },
|
|
on_attach = function(client, bufnr)
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
end,
|
|
settings = { powershell = { codeFormatting = { Preset = 'OTBS' } } },
|
|
}
|
|
end,
|
|
},
|
|
}
|
|
-- Godot's LSP - Requires Godot to be running
|
|
if vim.fn.has 'win32' == 1 then
|
|
require('lspconfig')['gdscript'].setup {
|
|
cmd = { 'ncat', '127.0.0.1', '6005' },
|
|
capabilities = require('blink.cmp').get_lsp_capabilities(),
|
|
name = 'godot',
|
|
}
|
|
else
|
|
require('lspconfig')['gdscript'].setup {
|
|
cmd = vim.lsp.rpc.connect('127.0.0.1', 6005),
|
|
name = 'godot',
|
|
}
|
|
end
|
|
end,
|
|
}
|