mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 16:46:45 +00:00
21fcace3ed
* flake: add lz.n and lzn-auto-require * lazy: init module * lzn-auto-require: add init lua code * wrapper: fix opt plugin format * lib.binds: add lz.n variant of bind functions * telescope: lazy load * nvim-tree: lazy load * dapui: lazy load * trouble: lazy load * toggleterm: lazy load * cheatsheet: lazy load * diffview: lazy load * icon-picker: lazy load * leap: lazy load * fidget: lazy load * docs: add section on lazy plugins * lazy: support lazy.enable=false * comment-nvim: lazy load * surround-nvim: lazy load * neo-tree: lazy load * fixup! lazy: init module * dap: appease the nix gods (fix statix lint) * flake.lock: fix merge mistake * doc: update release note * fixup! doc: update release note * neo-tree: fix duplicate neo-tree install * lazy: use attrsOf for lazy.plugins * treewide: update lazy.plugins syntax * docs: update lazy.plugins syntax * lazy: cleanup * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * formatting nitpick Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :3 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :4 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * flake: update lz.n * lazy: update lz.n plugin spec * lazy: allow lines in place of str for lua code * copilot: lazy load * cmp: lazy load this moves cmp itself to lazy.plugins but other plugins that call cmp are not yet lazy so cmp is technically not yet lazy * luasnip: lazy load * flake: add rtp.nvim * cmp: actually lazy load source * fixup! cmp: actually lazy load source * format * docs: fix broken link * cmp-nvim-lsp: lazy load * lazy: allow key mode of str type * cmp: install sourcess via cmp.sourcePlugins * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * lazy: refactor common var * nvim-dap-ui: add setupOpts * refactor: re-order plugin and lz.n configs lazy: make lzn-auto-require togglable * docs: update dag-entries * trouble: remove redundant import * lazy: remove unused module arg * toggleterm: make lazygit keybind optional * toggleterm: use toLuaObject for clarity * surround: rework keymap config * remove stale FIXME * lsp: use cmp_nvim_lsp capabilities * cmp: deduplicate attr key * theme: ensure themes load before lazy plugins * doc: update description of `theme` dag entry * lsp: avoid loading cmp on startup * doc: update configuration docs on custom plugins * cmp: skip trigger_load if lazy disabled * treesitter: remove redundant code * lsp: mark hack as HACK * comment: remove redundant plugin * Squash merge v0.7 into feature/lzn --------- Co-authored-by: raf <raf@notashelf.dev> Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
177 lines
6.5 KiB
Nix
177 lines
6.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
inherit (lib.modules) mkIf;
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.trivial) boolToString;
|
|
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
|
|
|
cfg = config.vim.lsp;
|
|
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
|
self = import ./module.nix {inherit config lib pkgs;};
|
|
|
|
mappingDefinitions = self.options.vim.lsp.mappings;
|
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
|
mkBinding = binding: action:
|
|
if binding.value != null
|
|
then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})"
|
|
else "";
|
|
in {
|
|
config = mkIf cfg.enable {
|
|
vim = {
|
|
autocomplete.nvim-cmp = {
|
|
sources = {nvim_lsp = "[LSP]";};
|
|
sourcePlugins = ["cmp-nvim-lsp"];
|
|
};
|
|
|
|
pluginRC.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 "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"}
|
|
${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 "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"}
|
|
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 ''
|
|
-- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we
|
|
-- should re-evaluate whether we can just use `default_capabilities`
|
|
capabilities = {
|
|
textDocument = {
|
|
completion = {
|
|
dynamicRegistration = false,
|
|
completionItem = {
|
|
snippetSupport = true,
|
|
commitCharactersSupport = true,
|
|
deprecatedSupport = true,
|
|
preselectSupport = true,
|
|
tagSupport = {
|
|
valueSet = {
|
|
1, -- Deprecated
|
|
}
|
|
},
|
|
insertReplaceSupport = true,
|
|
resolveSupport = {
|
|
properties = {
|
|
"documentation",
|
|
"detail",
|
|
"additionalTextEdits",
|
|
"sortText",
|
|
"filterText",
|
|
"insertText",
|
|
"textEdit",
|
|
"insertTextFormat",
|
|
"insertTextMode",
|
|
},
|
|
},
|
|
insertTextModeSupport = {
|
|
valueSet = {
|
|
1, -- asIs
|
|
2, -- adjustIndentation
|
|
}
|
|
},
|
|
labelDetailsSupport = true,
|
|
},
|
|
contextSupport = true,
|
|
insertTextMode = 1,
|
|
completionList = {
|
|
itemDefaults = {
|
|
'commitCharacters',
|
|
'editRange',
|
|
'insertTextFormat',
|
|
'insertTextMode',
|
|
'data',
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
''}
|
|
'';
|
|
};
|
|
};
|
|
}
|