mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 02:41:33 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
120
modules/plugins/lsp/config.nix
Normal file
120
modules/plugins/lsp/config.nix
Normal file
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
self = import ./module.nix {inherit config lib pkgs;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = optional usingNvimCmp "cmp-nvim-lsp";
|
||||
|
||||
autocomplete.sources = {"nvim_lsp" = "[LSP]";};
|
||||
|
||||
luaConfigRC.lsp-setup = ''
|
||||
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
||||
|
||||
local attach_keymaps = function(client, bufnr)
|
||||
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
|
||||
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
|
||||
${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
|
||||
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
|
||||
${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
|
||||
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
|
||||
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
|
||||
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
|
||||
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
|
||||
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
|
||||
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
|
||||
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"}
|
||||
${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"}
|
||||
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
|
||||
${mkBinding mappings.hover "vim.lsp.buf.hover()"}
|
||||
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
|
||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
||||
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
||||
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
|
||||
end
|
||||
|
||||
-- Enable formatting
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
format_callback = function(client, bufnr)
|
||||
if vim.g.formatsave then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
${
|
||||
if config.vim.lsp.null-ls.enable
|
||||
then ''
|
||||
if vim.b.disableFormatSave then
|
||||
return
|
||||
end
|
||||
|
||||
local function is_null_ls_formatting_enabled(bufnr)
|
||||
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||
local generators = require("null-ls.generators").get_available(
|
||||
file_type,
|
||||
require("null-ls.methods").internal.FORMATTING
|
||||
)
|
||||
return #generators > 0
|
||||
end
|
||||
|
||||
if is_null_ls_formatting_enabled(bufnr) then
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
filter = function(client)
|
||||
return client.name == "null-ls"
|
||||
end
|
||||
})
|
||||
else
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
})
|
||||
end
|
||||
''
|
||||
else "
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
})
|
||||
"
|
||||
}
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''}
|
||||
default_on_attach = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr)
|
||||
format_callback(client, bufnr)
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''
|
||||
-- let navic attach to buffers
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
navic.attach(client, bufnr)
|
||||
end
|
||||
''}
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
21
modules/plugins/lsp/default.nix
Normal file
21
modules/plugins/lsp/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
imports = [
|
||||
# nvim lsp support
|
||||
./config.nix
|
||||
./module.nix
|
||||
|
||||
./lspconfig
|
||||
./lspsaga
|
||||
./null-ls
|
||||
|
||||
# lsp plugins
|
||||
./lspsaga
|
||||
./nvim-code-action-menu
|
||||
./trouble
|
||||
./lsp-signature
|
||||
./lightbulb
|
||||
./lspkind
|
||||
./lsplines
|
||||
./nvim-docs-view
|
||||
];
|
||||
}
|
23
modules/plugins/lsp/lightbulb/config.nix
Normal file
23
modules/plugins/lsp/lightbulb/config.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lightbulb"];
|
||||
|
||||
luaConfigRC.lightbulb = entryAnywhere ''
|
||||
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
|
||||
|
||||
-- Enable trouble diagnostics viewer
|
||||
require'nvim-lightbulb'.setup()
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/lightbulb/default.nix
Normal file
6
modules/plugins/lsp/lightbulb/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./lightbulb.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
9
modules/plugins/lsp/lightbulb/lightbulb.nix
Normal file
9
modules/plugins/lsp/lightbulb/lightbulb.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lightbulb = {
|
||||
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
||||
};
|
||||
};
|
||||
}
|
29
modules/plugins/lsp/lsp-signature/config.nix
Normal file
29
modules/plugins/lsp/lsp-signature/config.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspSignature.enable) {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"lsp-signature"
|
||||
];
|
||||
|
||||
lsp.lspSignature.setupOpts = {
|
||||
bind = config.vim.ui.borders.plugins.lsp-signature.enable;
|
||||
handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style;
|
||||
};
|
||||
|
||||
luaConfigRC.lsp-signature = entryAnywhere ''
|
||||
-- Enable lsp signature viewer
|
||||
require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/lsp-signature/default.nix
Normal file
6
modules/plugins/lsp/lsp-signature/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./lsp-signature.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
10
modules/plugins/lsp/lsp-signature/lsp-signature.nix
Normal file
10
modules/plugins/lsp/lsp-signature/lsp-signature.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lspSignature = {
|
||||
enable = mkEnableOption "lsp signature viewer";
|
||||
setupOpts = lib.nvim.types.mkPluginSetupOption "lsp-signature" {};
|
||||
};
|
||||
};
|
||||
}
|
35
modules/plugins/lsp/lspconfig/config.nix
Normal file
35
modules/plugins/lsp/lspconfig/config.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf cfg.lspconfig.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
lsp.enable = true;
|
||||
|
||||
startPlugins = ["nvim-lspconfig"];
|
||||
|
||||
luaConfigRC.lspconfig = entryAfter ["lsp-setup"] ''
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
${
|
||||
optionalString config.vim.ui.borders.enable ''
|
||||
require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}'
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
{
|
||||
vim.luaConfigRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources;
|
||||
}
|
||||
]);
|
||||
}
|
6
modules/plugins/lsp/lspconfig/default.nix
Normal file
6
modules/plugins/lsp/lspconfig/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./lspconfig.nix
|
||||
];
|
||||
}
|
14
modules/plugins/lsp/lspconfig/lspconfig.nix
Normal file
14
modules/plugins/lsp/lspconfig/lspconfig.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf str;
|
||||
in {
|
||||
options.vim.lsp.lspconfig = {
|
||||
enable = mkEnableOption "nvim-lspconfig, also enabled automatically";
|
||||
|
||||
sources = mkOption {
|
||||
description = "nvim-lspconfig sources";
|
||||
type = attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
20
modules/plugins/lsp/lspkind/config.nix
Normal file
20
modules/plugins/lsp/lspkind/config.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspkind.enable) {
|
||||
vim.startPlugins = ["lspkind"];
|
||||
vim.luaConfigRC.lspkind = entryAnywhere ''
|
||||
local lspkind = require'lspkind'
|
||||
local lspkind_opts = {
|
||||
mode = '${cfg.lspkind.mode}'
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/lspkind/default.nix
Normal file
6
modules/plugins/lsp/lspkind/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./lspkind.nix
|
||||
];
|
||||
}
|
16
modules/plugins/lsp/lspkind/lspkind.nix
Normal file
16
modules/plugins/lsp/lspkind/lspkind.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) enum;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lspkind = {
|
||||
enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]";
|
||||
|
||||
mode = mkOption {
|
||||
description = "Defines how annotations are shown";
|
||||
type = enum ["text" "text_symbol" "symbol_text" "symbol"];
|
||||
default = "symbol_text";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
21
modules/plugins/lsp/lsplines/config.nix
Normal file
21
modules/plugins/lsp/lsplines/config.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lsplines.enable) {
|
||||
vim.startPlugins = ["lsp-lines"];
|
||||
vim.luaConfigRC.lsplines = entryAfter ["lspconfig"] ''
|
||||
require("lsp_lines").setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/lsplines/default.nix
Normal file
6
modules/plugins/lsp/lsplines/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./lsplines.nix
|
||||
];
|
||||
}
|
11
modules/plugins/lsp/lsplines/lsplines.nix
Normal file
11
modules/plugins/lsp/lsplines/lsplines.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lsplines = {
|
||||
enable = mkEnableOption ''
|
||||
diagnostics using virtual lines on top of the real line of code. [lsp_lines]
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
53
modules/plugins/lsp/lspsaga/config.nix
Normal file
53
modules/plugins/lsp/lspsaga/config.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
self = import ./lspsaga.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim = {
|
||||
startPlugins = ["lspsaga"];
|
||||
|
||||
maps = {
|
||||
visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||
|
||||
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||
|
||||
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||
|
||||
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||
|
||||
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||
|
||||
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||
];
|
||||
};
|
||||
|
||||
luaConfigRC.lspsaga = entryAnywhere ''
|
||||
require('lspsaga').init_lsp_saga({
|
||||
${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
|
||||
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
|
||||
''}
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/lspsaga/default.nix
Normal file
6
modules/plugins/lsp/lspsaga/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./lspsaga.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
29
modules/plugins/lsp/lspsaga/lspsaga.nix
Normal file
29
modules/plugins/lsp/lspsaga/lspsaga.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
|
||||
|
||||
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
|
||||
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
|
||||
|
||||
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
|
||||
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
|
||||
|
||||
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
|
||||
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
|
||||
|
||||
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
|
||||
|
||||
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<leader>ls";
|
||||
};
|
||||
};
|
||||
}
|
71
modules/plugins/lsp/module.nix
Normal file
71
modules/plugins/lsp/module.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
enable = mkEnableOption "LSP, also enabled automatically through null-ls and lspconfig options";
|
||||
formatOnSave = mkEnableOption "format on save";
|
||||
mappings = {
|
||||
goToDefinition =
|
||||
mkMappingOption "Go to definition"
|
||||
"<leader>lgd";
|
||||
goToDeclaration =
|
||||
mkMappingOption "Go to declaration"
|
||||
"<leader>lgD";
|
||||
goToType =
|
||||
mkMappingOption "Go to type"
|
||||
"<leader>lgt";
|
||||
listImplementations =
|
||||
mkMappingOption "List implementations"
|
||||
"<leader>lgi";
|
||||
listReferences =
|
||||
mkMappingOption "List references"
|
||||
"<leader>lgr";
|
||||
nextDiagnostic =
|
||||
mkMappingOption "Go to next diagnostic"
|
||||
"<leader>lgn";
|
||||
previousDiagnostic =
|
||||
mkMappingOption "Go to previous diagnostic"
|
||||
"<leader>lgp";
|
||||
openDiagnosticFloat =
|
||||
mkMappingOption "Open diagnostic float"
|
||||
"<leader>le";
|
||||
documentHighlight =
|
||||
mkMappingOption "Document highlight"
|
||||
"<leader>lH";
|
||||
listDocumentSymbols =
|
||||
mkMappingOption "List document symbols"
|
||||
"<leader>lS";
|
||||
addWorkspaceFolder =
|
||||
mkMappingOption "Add workspace folder"
|
||||
"<leader>lwa";
|
||||
removeWorkspaceFolder =
|
||||
mkMappingOption "Remove workspace folder"
|
||||
"<leader>lwr";
|
||||
listWorkspaceFolders =
|
||||
mkMappingOption "List workspace folders"
|
||||
"<leader>lwl";
|
||||
listWorkspaceSymbols =
|
||||
mkMappingOption "List workspace symbols"
|
||||
"<leader>lws";
|
||||
hover =
|
||||
mkMappingOption "Trigger hover"
|
||||
"<leader>lh";
|
||||
signatureHelp =
|
||||
mkMappingOption "Signature help"
|
||||
"<leader>ls";
|
||||
renameSymbol =
|
||||
mkMappingOption "Rename symbol"
|
||||
"<leader>ln";
|
||||
codeAction =
|
||||
mkMappingOption "Code action"
|
||||
"<leader>la";
|
||||
format =
|
||||
mkMappingOption "Format"
|
||||
"<leader>lf";
|
||||
toggleFormatOnSave =
|
||||
mkMappingOption "Toggle format on save"
|
||||
"<leader>ltf";
|
||||
};
|
||||
};
|
||||
}
|
41
modules/plugins/lsp/null-ls/config.nix
Normal file
41
modules/plugins/lsp/null-ls/config.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf cfg.null-ls.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
lsp.enable = true;
|
||||
startPlugins = ["none-ls"];
|
||||
|
||||
luaConfigRC.null_ls-setup = entryAnywhere ''
|
||||
local null_ls = require("null-ls")
|
||||
local null_helpers = require("null-ls.helpers")
|
||||
local null_methods = require("null-ls.methods")
|
||||
local ls_sources = {}
|
||||
'';
|
||||
|
||||
luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
|
||||
require('null-ls').setup({
|
||||
debug = false,
|
||||
diagnostics_format = "[#{m}] #{s} (#{c})",
|
||||
debounce = 250,
|
||||
default_timeout = 5000,
|
||||
sources = ls_sources,
|
||||
on_attach = default_on_attach
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
{
|
||||
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
|
||||
}
|
||||
]);
|
||||
}
|
6
modules/plugins/lsp/null-ls/default.nix
Normal file
6
modules/plugins/lsp/null-ls/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./null-ls.nix
|
||||
];
|
||||
}
|
14
modules/plugins/lsp/null-ls/null-ls.nix
Normal file
14
modules/plugins/lsp/null-ls/null-ls.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf str;
|
||||
in {
|
||||
options.vim.lsp.null-ls = {
|
||||
enable = mkEnableOption "null-ls, also enabled automatically";
|
||||
|
||||
sources = mkOption {
|
||||
description = "null-ls sources";
|
||||
type = attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
37
modules/plugins/lsp/nvim-code-action-menu/config.nix
Normal file
37
modules/plugins/lsp/nvim-code-action-menu/config.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
self = import ./nvim-code-action-menu.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-code-action-menu"];
|
||||
|
||||
maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>c" = "+CodeAction";
|
||||
};
|
||||
|
||||
luaConfigRC.code-action-menu = entryAnywhere ''
|
||||
-- border configuration
|
||||
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'
|
||||
|
||||
-- show individual sections of the code action menu
|
||||
${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"}
|
||||
${lib.optionalString cfg.nvimCodeActionMenu.show.diff "vim.g.code_action_menu_show_diff = true"}
|
||||
${lib.optionalString cfg.nvimCodeActionMenu.show.actionKind "vim.g.code_action_menu_show_action_kind = true"}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/nvim-code-action-menu/default.nix
Normal file
6
modules/plugins/lsp/nvim-code-action-menu/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nvim-code-action-menu.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
nvimCodeActionMenu = {
|
||||
enable = mkEnableOption "nvim code action menu";
|
||||
|
||||
show = {
|
||||
details = mkEnableOption "Show details" // {default = true;};
|
||||
diff = mkEnableOption "Show diff" // {default = true;};
|
||||
actionKind = mkEnableOption "Show action kind" // {default = true;};
|
||||
};
|
||||
|
||||
mappings = {
|
||||
open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "<leader>ca";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
32
modules/plugins/lsp/nvim-docs-view/config.nix
Normal file
32
modules/plugins/lsp/nvim-docs-view/config.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.lsp.nvim-docs-view;
|
||||
self = import ./nvim-docs-view.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.nvim-docs-view.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
lsp.enable = true;
|
||||
startPlugins = ["nvim-docs-view"];
|
||||
|
||||
luaConfigRC.nvim-docs-view = entryAnywhere ''
|
||||
require("docs-view").setup ${toLuaObject cfg.setupOpts}
|
||||
'';
|
||||
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.viewToggle "<cmd>DocsViewToggle<CR>")
|
||||
(mkSetBinding mappings.viewUpdate "<cmd>DocsViewUpdate<CR>")
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/nvim-docs-view/default.nix
Normal file
6
modules/plugins/lsp/nvim-docs-view/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-docs-view.nix
|
||||
];
|
||||
}
|
62
modules/plugins/lsp/nvim-docs-view/nvim-docs-view.nix
Normal file
62
modules/plugins/lsp/nvim-docs-view/nvim-docs-view.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib) types mkRenamedOptionModule;
|
||||
in {
|
||||
imports = let
|
||||
renamedSetupOption = oldPath: newPath:
|
||||
mkRenamedOptionModule
|
||||
(["vim" "lsp" "nvim-docs-view"] ++ oldPath)
|
||||
(["vim" "lsp" "nvim-docs-view" "setupOpts"] ++ newPath);
|
||||
in [
|
||||
(renamedSetupOption ["position"] ["position"])
|
||||
(renamedSetupOption ["width"] ["width"])
|
||||
(renamedSetupOption ["height"] ["height"])
|
||||
(renamedSetupOption ["updateMode"] ["update_mode"])
|
||||
];
|
||||
|
||||
options.vim.lsp.nvim-docs-view = {
|
||||
enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";
|
||||
|
||||
setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" {
|
||||
position = mkOption {
|
||||
type = types.enum ["left" "right" "top" "bottom"];
|
||||
default = "right";
|
||||
description = ''
|
||||
Where to open the docs view panel
|
||||
'';
|
||||
};
|
||||
|
||||
height = mkOption {
|
||||
type = types.int;
|
||||
default = 10;
|
||||
description = ''
|
||||
Height of the docs view panel if the position is set to either top or bottom
|
||||
'';
|
||||
};
|
||||
|
||||
width = mkOption {
|
||||
type = types.int;
|
||||
default = 60;
|
||||
description = ''
|
||||
Width of the docs view panel if the position is set to either left or right
|
||||
'';
|
||||
};
|
||||
|
||||
update_mode = mkOption {
|
||||
type = types.enum ["auto" "manual"];
|
||||
default = "auto";
|
||||
description = ''
|
||||
Determines the mechanism used to update the docs view panel content.
|
||||
- If auto, the content will update upon cursor move.
|
||||
- If manual, the content will only update once :DocsViewUpdate is called
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
mappings = {
|
||||
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";
|
||||
viewUpdate = mkMappingOption "Manually update the docs view panel" "lvu";
|
||||
};
|
||||
};
|
||||
}
|
41
modules/plugins/lsp/trouble/config.nix
Normal file
41
modules/plugins/lsp/trouble/config.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding pushDownDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
self = import ./trouble.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||
vim = {
|
||||
startPlugins = ["trouble"];
|
||||
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>l" = "Trouble";
|
||||
"<leader>x" = "+Trouble";
|
||||
"<leader>lw" = "Workspace";
|
||||
};
|
||||
|
||||
luaConfigRC.trouble = entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
require("trouble").setup {}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/lsp/trouble/default.nix
Normal file
6
modules/plugins/lsp/trouble/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./trouble.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
19
modules/plugins/lsp/trouble/trouble.nix
Normal file
19
modules/plugins/lsp/trouble/trouble.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
trouble = {
|
||||
enable = mkEnableOption "trouble diagnostics viewer";
|
||||
|
||||
mappings = {
|
||||
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
|
||||
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
||||
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
|
||||
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
|
||||
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
|
||||
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue