Replace multiple plugins with mini.nvim
This commit is contained in:
parent
92511131d1
commit
c2e9b1ae51
7 changed files with 164 additions and 162 deletions
|
@ -1,82 +1,86 @@
|
|||
local lsp = require("lsp-zero")
|
||||
-- settings erro signs
|
||||
local function sign_define(args)
|
||||
vim.fn.sign_define(args.name, {
|
||||
texthl = args.name,
|
||||
text = args.text,
|
||||
numhl = "",
|
||||
})
|
||||
end
|
||||
|
||||
lsp.extend_cmp()
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-l>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<Tab>"] = nil,
|
||||
["<S-Tab>"] = nil,
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "luasnip" },
|
||||
},
|
||||
})
|
||||
|
||||
lsp.set_sign_icons({
|
||||
error = "E",
|
||||
warn = "W",
|
||||
hint = "H",
|
||||
info = "I",
|
||||
})
|
||||
|
||||
lsp.extend_lspconfig()
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
|
||||
vim.keymap.set("n", "gd", function()
|
||||
vim.lsp.buf.definition()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function()
|
||||
vim.lsp.buf.workspace_symbol()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function()
|
||||
vim.diagnostic.open_float()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "[d", function()
|
||||
vim.diagnostic.goto_next()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "]d", function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function()
|
||||
vim.lsp.buf.references()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function()
|
||||
vim.lsp.buf.rename()
|
||||
end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end, opts)
|
||||
end)
|
||||
sign_define({ name = "DiagnosticSignError", text = "E" })
|
||||
sign_define({ name = "DiagnosticSignWarn", text = "W" })
|
||||
sign_define({ name = "DiagnosticSignHint", text = "H" })
|
||||
sign_define({ name = "DiagnosticSignInfo", text = "I" })
|
||||
|
||||
-- enable diagnostics virtual text
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
})
|
||||
|
||||
-- diagnostic's aren't lsp dependent
|
||||
vim.keymap.set("n", "<leader>vd", function()
|
||||
vim.diagnostic.open_float()
|
||||
end)
|
||||
vim.keymap.set("n", "[d", function()
|
||||
vim.diagnostic.goto_next()
|
||||
end)
|
||||
vim.keymap.set("n", "]d", function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end)
|
||||
|
||||
-- lsp related bindings
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
desc = "LSP Actions",
|
||||
callback = function(event)
|
||||
local opts = { buffer = event.buf }
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "gd", function()
|
||||
vim.lsp.buf.definition()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "gD", function()
|
||||
vim.lsp.buf.declaration()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "gi", function()
|
||||
vim.lsp.buf.implementation()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>lca", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>lrn", function()
|
||||
vim.lsp.buf.rename()
|
||||
end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- setup mason and automatically install some language server's
|
||||
require("mason").setup({})
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "lua_ls", "jsonls", "bashls", "pyright", "marksman", "gopls" },
|
||||
handlers = {
|
||||
lsp.default_setup,
|
||||
},
|
||||
ensure_installed = { "lua_ls", "jsonls", "bashls", "pyright", "marksman", "gopls", "clangd" },
|
||||
})
|
||||
|
||||
-- automatically setup already installed lsp's
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup({})
|
||||
end,
|
||||
})
|
||||
|
||||
-- setup haskell language server manually cause it doesn't work with mason for xmonad
|
||||
require("lspconfig").hls.setup({})
|
||||
|
||||
-- autocompletion using mini.completion
|
||||
require("mini.completion").setup({
|
||||
lsp_completion = {
|
||||
source_func = "omnifunc",
|
||||
},
|
||||
fallback_action = "<C-x><C-n>",
|
||||
})
|
||||
|
||||
-- bind ctrl j and k to move beetwen completion items
|
||||
vim.keymap.set("i", "<C-j>", [[pumvisible() ? "\<C-n>" : "\<C-j>"]], { expr = true })
|
||||
vim.keymap.set("i", "<C-k>", [[pumvisible() ? "\<C-p>" : "\<C-k>"]], { expr = true })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue