nix/home-manager/common/software/cli/nixvim.nix

154 lines
4.6 KiB
Nix
Raw Normal View History

2024-02-16 07:39:00 +01:00
{ ... }: {
imports = [ ./nixvim/base.nix ];
2024-02-08 03:17:11 +01:00
2024-02-16 09:56:55 +01:00
programs.nixvim = {
2024-04-03 01:28:13 +02:00
extraConfigLuaPost = ''
local _border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = _border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help, {
border = _border
}
)
vim.diagnostic.config{
float={border=_border}
}
vim.cmd [[nnoremap <buffer><silent> <C-space> :lua vim.lsp.diagnostic.show_line_diagnostics({ border = "single" })<CR>]]
vim.cmd [[nnoremap <buffer><silent> ]g :lua vim.lsp.diagnostic.goto_next({ popup_opts = { border = "single" }})<CR>]]
vim.cmd [[nnoremap <buffer><silent> [g :lua vim.lsp.diagnostic.goto_prev({ popup_opts = { border = "single" }})<CR>]]
vim.diagnostic.config { float={border=_border} }
require('lspconfig.ui.windows').default_options = { border = _border }
local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or border
return orig_util_open_floating_preview(contents, syntax, opts, ...)
end
vim.diagnostic.config({
virtual_text = {
prefix = '',
}
})
LspDiagnosticsFloatingError = {fg=color1,bg=none,style='bold'};
LspDiagnosticsFloatingWarning = {fg=color2,bg=none,style='bold'};
LspDiagnosticsFloatingInformation = {fg=color3,bg=none,style='italic'};
LspDiagnosticsFloatingHint = {fg=color4,bg=none,style='italic'};
'';
2024-02-16 09:56:55 +01:00
plugins = {
2024-04-02 04:19:43 +02:00
lsp-lines.enable = false;
2024-04-01 06:20:09 +02:00
lsp-lines.currentLine = true;
2024-03-30 07:27:21 +01:00
crates-nvim.enable = true;
2024-02-16 09:56:55 +01:00
lsp = {
enable = true;
servers = {
rust-analyzer = {
enable = true;
installCargo = true;
installRustc = true;
};
pylsp = {
enable = true;
autostart = true;
installLanguageServer = true;
settings = {
plugins = {
black = {
enabled = true;
preview = true;
2024-02-08 03:42:16 +01:00
};
2024-02-16 09:56:55 +01:00
jedi_completion = {
enabled = true;
fuzzy = true;
2024-02-13 06:19:41 +01:00
};
2024-02-16 09:56:55 +01:00
pylint.enabled = true;
2024-02-16 10:56:48 +01:00
pylsp_mypy.enabled = true;
2024-02-16 09:56:55 +01:00
};
};
};
nil_ls.enable = true;
html.enable = true;
cssls.enable = true;
bashls.enable = true;
2024-04-02 04:19:43 +02:00
tailwindcss.enable = true;
svelte.enable = true;
2024-02-16 09:56:55 +01:00
};
2024-04-03 01:28:13 +02:00
onAttach = ''
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = 'rounded',
source = 'always',
prefix = ' ',
scope = 'cursor',
}
vim.diagnostic.open_float(nil, opts)
end
})
'';
2024-02-16 09:56:55 +01:00
keymaps = {
2024-04-03 01:28:13 +02:00
silent = false;
2024-02-16 09:56:55 +01:00
diagnostic = {
"<leader>lk" = {
action = "goto_prev";
desc = "Go to prev";
};
"<leader>lj" = {
action = "goto_next";
desc = "Go to next";
};
};
lspBuf = {
K = {
action = "hover";
desc = "Hover";
};
"<leader>lr" = {
action = "references";
desc = "LSP [r]eferences";
};
"<leader>ld" = {
action = "definition";
desc = "LSP [d]efinitions";
};
"<leader>li" = {
action = "implementation";
desc = "LSP [i]implementations";
};
"<leader>lt" = {
action = "type_definition";
desc = "LSP [t]ype definitions";
};
"<leader>la" = {
action = "code_action";
desc = "LSP Code [A]ctions";
2024-02-08 03:42:16 +01:00
};
2024-02-16 09:56:55 +01:00
};
2024-02-08 03:17:11 +01:00
};
2024-02-16 09:56:55 +01:00
};
2024-02-08 03:17:11 +01:00
};
2024-02-16 09:56:55 +01:00
};
2024-02-08 11:08:43 +01:00
}