dotfiles-guix/home/config/nvim/lua/lsp.lua

93 lines
2.2 KiB
Lua
Raw Normal View History

2024-06-22 02:52:21 +00:00
local lsp = require('lsp-zero').preset('recommended')
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {
'eslint',
'rust_analyzer',
'clangd',
'html',
'cssls',
'pyright',
'vimls',
'yamlls',
'bashls',
'lua_ls',
},
handlers = {
lsp.default_setup,
},
})
local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = cmp.mapping.preset.insert({
2024-10-18 04:04:03 +00:00
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
2024-06-22 02:52:21 +00:00
})
cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil
cmp.setup({
mapping = cmp_mappings
})
lsp.set_preferences({
2024-10-18 04:04:03 +00:00
suggest_lsp_servers = false,
sign_icons = {
error = 'E',
warn = 'W',
hint = 'H',
info = 'I'
}
2024-06-22 02:52:21 +00:00
})
lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
local keymap = vim.keymap.set
keymap("n", "gd", function() vim.lsp.buf.definition() end, opts)
2024-10-18 04:04:03 +00:00
keymap("n", "K", function() vim.lsp.buf.hover() end, opts)
keymap("n", "<leader>ls", function() vim.lsp.buf.workspace_symbol() end, opts)
keymap("n", "<leader>lf", function() vim.diagnostic.open_float() end, opts)
keymap("n", "[d", function() vim.diagnostic.goto_next() end, opts)
keymap("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
keymap("n", "<leader>la", function() vim.lsp.buf.code_action() end, opts)
keymap("n", "<leader>lr", function() vim.lsp.buf.references() end, opts)
keymap("n", "<leader>ln", function() vim.lsp.buf.rename() end, opts)
keymap("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
2024-06-22 02:52:21 +00:00
end)
require('lspconfig/prolog_lsp')
require('lspconfig').gleam.setup {}
lsp.configure('prolog_lsp', {force_setup = true})
lsp.setup()
require('phpactor').setup {
install = {
branch = "master",
bin = "/usr/bin/phpactor",
php_bin = "php",
composer_bin = "composer",
git_bin = "git",
check_on_startup = "none",
},
lspconfig = {
enabled = true,
options = {},
},
}
vim.diagnostic.config({
2024-10-18 04:04:03 +00:00
virtual_text = true
2024-06-22 02:52:21 +00:00
})
require("neodev").setup()
require("nvim-surround").setup()