2023-02-26 13:20:49 +01:00
|
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
|
|
|
vim.keymap.set('n', ',d', vim.diagnostic.goto_prev, opts)
|
|
|
|
vim.keymap.set('n', '.d', vim.diagnostic.goto_next, opts)
|
|
|
|
|
|
|
|
local lsp_attach = function(client, buf)
|
|
|
|
vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
|
|
|
|
vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
|
|
|
vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
|
|
|
|
2024-08-13 07:47:26 +02:00
|
|
|
vim.lsp.inlay_hint.enable(true, nil)
|
2024-01-17 15:10:36 +01:00
|
|
|
|
2023-02-26 13:20:49 +01:00
|
|
|
local bufopts = { noremap = true, silent = true, buffer = buf }
|
|
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
|
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
|
|
end
|
|
|
|
|
2023-04-03 12:40:26 +02:00
|
|
|
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/packages/codelldb/extension/")
|
|
|
|
local codelldb_path = mason_path .. "adapter/codelldb"
|
|
|
|
local liblldb_path = mason_path .. "lldb/lib/liblldb.so"
|
|
|
|
|
|
|
|
if vim.fn.has "mac" == 1 then
|
|
|
|
liblldb_path = mason_path .. "lldb/lib/liblldb.dylib"
|
|
|
|
end
|
|
|
|
|
2023-02-24 21:11:27 +01:00
|
|
|
return {
|
|
|
|
-- lsp
|
2023-02-26 13:20:49 +01:00
|
|
|
{
|
|
|
|
'williamboman/mason.nvim',
|
|
|
|
config = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'williamboman/mason-lspconfig.nvim',
|
|
|
|
config = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'neovim/nvim-lspconfig',
|
|
|
|
config = function()
|
|
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
|
|
local lspconfig = require('lspconfig')
|
|
|
|
|
|
|
|
lspconfig.lua_ls.setup {
|
|
|
|
capabilities = capabilities,
|
2023-03-03 11:42:28 +01:00
|
|
|
root_dir = lspconfig.util.root_pattern('.git'),
|
2023-02-26 13:20:49 +01:00
|
|
|
settings = {
|
|
|
|
Lua = {
|
2023-03-03 11:42:28 +01:00
|
|
|
runtime = {
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
version = 'LuaJIT',
|
|
|
|
},
|
2023-02-26 13:20:49 +01:00
|
|
|
diagnostics = {
|
2023-03-03 11:42:28 +01:00
|
|
|
-- Get the language server to recognize the `vim` global
|
2023-02-26 13:20:49 +01:00
|
|
|
globals = { 'vim' }
|
2023-03-03 11:42:28 +01:00
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
2023-04-03 12:40:26 +02:00
|
|
|
checkThirdParty = false,
|
2023-03-03 11:42:28 +01:00
|
|
|
},
|
2023-02-26 13:20:49 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
on_attach = lsp_attach
|
|
|
|
}
|
|
|
|
lspconfig.tsserver.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
}
|
|
|
|
lspconfig.gopls.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
}
|
|
|
|
--lspconfig.rust_analyzer.setup {
|
|
|
|
-- capabilities = capabilities,
|
|
|
|
-- on_attach = lsp_attach
|
|
|
|
--}
|
|
|
|
lspconfig.bashls.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
}
|
|
|
|
lspconfig.sqlls.setup({
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
lspconfig.html.setup({
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
lspconfig.cssls.setup({
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
lspconfig.tailwindcss.setup({
|
|
|
|
capabilities = capabilities,
|
2023-04-03 12:40:26 +02:00
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
lspconfig.phpactor.setup({
|
|
|
|
capabilities = capabilities,
|
2023-02-26 13:20:49 +01:00
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
lspconfig.emmet_ls.setup({
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = lsp_attach
|
|
|
|
})
|
|
|
|
end
|
|
|
|
},
|
2024-01-17 15:10:36 +01:00
|
|
|
{
|
|
|
|
'mrcjkb/rustaceanvim',
|
2024-08-13 07:47:26 +02:00
|
|
|
version = "^4",
|
|
|
|
lazy = false,
|
2024-01-17 15:10:36 +01:00
|
|
|
ft = { "rust" },
|
|
|
|
config = function()
|
|
|
|
vim.g.rustaceanvim = {
|
|
|
|
server = {
|
|
|
|
on_attach = lsp_attach,
|
|
|
|
settings = {
|
|
|
|
-- rust-analyzer language server configuration
|
|
|
|
["rust-analyzer"] = {
|
|
|
|
rustfmt = {
|
|
|
|
extraArgs = { "+nightly" },
|
|
|
|
},
|
|
|
|
cargo = {
|
|
|
|
allFeatures = true,
|
|
|
|
loadOutDirsFromCheck = true,
|
|
|
|
runBuildScripts = true,
|
|
|
|
},
|
|
|
|
-- Add clippy lints for Rust.
|
|
|
|
checkOnSave = {
|
|
|
|
allFeatures = true,
|
|
|
|
command = "clippy",
|
|
|
|
extraArgs = { "--no-deps" },
|
|
|
|
},
|
|
|
|
-- TODO this breaks diagnostics, look into what can be done
|
|
|
|
-- procMacro = {
|
|
|
|
-- enable = true,
|
|
|
|
-- ignored = {
|
|
|
|
-- ["async-trait"] = { "async_trait" },
|
|
|
|
-- ["napi-derive"] = { "napi" },
|
|
|
|
-- ["async-recursion"] = { "async_recursion" },
|
|
|
|
-- },
|
|
|
|
-- },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
},
|
2023-02-24 21:11:27 +01:00
|
|
|
{ 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga
|
2023-02-26 13:34:44 +01:00
|
|
|
{
|
|
|
|
'j-hui/fidget.nvim',
|
|
|
|
config = true
|
|
|
|
}, -- show lsp status
|
2023-02-24 21:11:27 +01:00
|
|
|
-- completion
|
|
|
|
{
|
|
|
|
'hrsh7th/nvim-cmp',
|
2023-02-26 13:34:44 +01:00
|
|
|
config = function()
|
2023-02-26 13:20:49 +01:00
|
|
|
local cmp = require('cmp')
|
|
|
|
local lspkind = require('lspkind')
|
|
|
|
|
|
|
|
vim.opt.shortmess:append 'c'
|
|
|
|
|
|
|
|
cmp.setup({
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
require('luasnip').lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
|
|
|
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
2023-09-23 14:54:20 +02:00
|
|
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
2023-02-26 13:20:49 +01:00
|
|
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
|
|
|
['<C-s>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
|
|
|
['<C-y>'] = cmp.mapping.confirm({
|
|
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
|
|
select = true
|
|
|
|
}),
|
|
|
|
['<C-e>'] = cmp.mapping({
|
|
|
|
i = cmp.mapping.abort(),
|
|
|
|
c = cmp.mapping.close(),
|
|
|
|
}),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
|
|
}),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'nvim_lua' },
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'path' },
|
|
|
|
{ name = 'luasnip' },
|
|
|
|
{ name = 'nvim_lsp_signature_help' },
|
2023-02-26 13:34:44 +01:00
|
|
|
}, {
|
|
|
|
{ name = 'buffer', keyword_length = 5 },
|
2023-02-26 13:20:49 +01:00
|
|
|
}),
|
|
|
|
formatting = {
|
|
|
|
format = lspkind.cmp_format {
|
|
|
|
with_text = true,
|
|
|
|
menu = {
|
|
|
|
buffer = "[buf]",
|
|
|
|
nvim_lsp = "[LSP]",
|
|
|
|
nvim_lua = "[api]",
|
|
|
|
path = "[path]",
|
|
|
|
luasnip = "[snip]",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use buffer source for `/` (basically search words in buffer)
|
|
|
|
cmp.setup.cmdline('/', {
|
|
|
|
sources = {
|
|
|
|
{ name = 'buffer' }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':'
|
|
|
|
cmp.setup.cmdline(':', {
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'path' }
|
2023-02-26 13:34:44 +01:00
|
|
|
}, {
|
|
|
|
{ name = 'cmdline' }
|
2023-02-26 13:20:49 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
end,
|
2023-02-24 21:11:27 +01:00
|
|
|
event = 'InsertEnter',
|
|
|
|
dependencies = {
|
|
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
|
|
'hrsh7th/cmp-nvim-lsp-signature-help',
|
|
|
|
'hrsh7th/cmp-buffer',
|
|
|
|
'hrsh7th/cmp-path',
|
|
|
|
'hrsh7th/cmp-nvim-lua',
|
|
|
|
'hrsh7th/cmp-cmdline',
|
|
|
|
'saadparwaiz1/cmp_luasnip',
|
|
|
|
}
|
2023-02-26 13:20:49 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'L3MON4D3/LuaSnip',
|
2024-01-03 13:17:03 +01:00
|
|
|
version = "v2.*",
|
|
|
|
build = "make install_jsregexp",
|
2023-02-26 13:20:49 +01:00
|
|
|
config = function()
|
|
|
|
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" })
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'windwp/nvim-autopairs',
|
|
|
|
config = true
|
|
|
|
},
|
2024-01-18 12:43:07 +01:00
|
|
|
{
|
|
|
|
"folke/trouble.nvim",
|
|
|
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
|
|
|
opts = {
|
|
|
|
-- your configuration comes here
|
|
|
|
-- or leave it empty to use the default settings
|
|
|
|
-- refer to the configuration section below
|
|
|
|
},
|
|
|
|
},
|
2023-02-24 21:11:27 +01:00
|
|
|
}
|