mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00:00
lsp: avoid vimscript in bindings
This commit is contained in:
parent
5ab1af9285
commit
0aa557dac6
1 changed files with 21 additions and 21 deletions
|
@ -18,7 +18,7 @@
|
||||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
mkBinding = binding: action:
|
mkBinding = binding: action:
|
||||||
if binding.value != null
|
if binding.value != null
|
||||||
then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
|
then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})"
|
||||||
else "";
|
else "";
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -31,26 +31,26 @@ in {
|
||||||
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
||||||
|
|
||||||
local attach_keymaps = function(client, bufnr)
|
local attach_keymaps = function(client, bufnr)
|
||||||
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
|
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration"}
|
||||||
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
|
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition"}
|
||||||
${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
|
${mkBinding mappings.goToType "vim.lsp.buf.type_definition"}
|
||||||
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
|
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation"}
|
||||||
${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
|
${mkBinding mappings.listReferences "vim.lsp.buf.references"}
|
||||||
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
|
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next"}
|
||||||
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
|
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev"}
|
||||||
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
|
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float"}
|
||||||
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
|
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight"}
|
||||||
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
|
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol"}
|
||||||
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
|
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder"}
|
||||||
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_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.listWorkspaceFolders "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"}
|
||||||
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
|
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol"}
|
||||||
${mkBinding mappings.hover "vim.lsp.buf.hover()"}
|
${mkBinding mappings.hover "vim.lsp.buf.hover"}
|
||||||
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
|
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help"}
|
||||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename"}
|
||||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
${mkBinding mappings.codeAction "vim.lsp.buf.code_action"}
|
||||||
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
${mkBinding mappings.format "vim.lsp.buf.format"}
|
||||||
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
|
${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable formatting
|
-- Enable formatting
|
||||||
|
|
Loading…
Reference in a new issue