Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 718:451632dcb1dd
feat: add lsp-format-modifications
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sat, 03 Dec 2022 22:22:10 +0100 |
parents | 787e0516daa5 |
children | 08baa6419e7d |
comparison
equal
deleted
inserted
replaced
717:164683291d2f | 718:451632dcb1dd |
---|---|
441 end, | 441 end, |
442 } | 442 } |
443 end, | 443 end, |
444 } | 444 } |
445 use { | 445 use { |
446 local_plugin 'lsp-format-modifications.nvim', | |
447 requires = { 'nvim-lua/plenary.nvim' }, | |
448 } | |
449 use { | |
446 'j-hui/fidget.nvim', | 450 'j-hui/fidget.nvim', |
447 config = function() | 451 config = function() |
448 require('fidget').setup { | 452 require('fidget').setup { |
449 text = { | 453 text = { |
450 spinner = 'dots', | 454 spinner = 'dots', |
1112 end, | 1116 end, |
1113 bufnr = bufnr, | 1117 bufnr = bufnr, |
1114 } | 1118 } |
1115 end | 1119 end |
1116 | 1120 |
1117 local on_attach = function(client) | 1121 local on_attach = function(client, bufnr) |
1118 local nmap = function(lhs, rhs, opts) return vim.keymap.set('n', lhs, rhs, opts) end | 1122 local nmap = function(lhs, rhs, opts) return vim.keymap.set('n', lhs, rhs, opts) end |
1119 | 1123 |
1120 nmap('gp', require('goto-preview').goto_preview_definition, { silent = true, buffer = 0 }) | 1124 nmap('gp', require('goto-preview').goto_preview_definition, { silent = true, buffer = 0 }) |
1121 nmap('gP', require('goto-preview').close_all_win, { silent = true, buffer = 0 }) | 1125 nmap('gP', require('goto-preview').close_all_win, { silent = true, buffer = 0 }) |
1122 | 1126 |
1126 nmap('1gD', vim.lsp.buf.type_definition, { silent = true, buffer = 0 }) | 1130 nmap('1gD', vim.lsp.buf.type_definition, { silent = true, buffer = 0 }) |
1127 nmap('gr', vim.lsp.buf.references, { silent = true, buffer = 0 }) | 1131 nmap('gr', vim.lsp.buf.references, { silent = true, buffer = 0 }) |
1128 nmap('g0', vim.lsp.buf.document_symbol, { silent = true, buffer = 0 }) | 1132 nmap('g0', vim.lsp.buf.document_symbol, { silent = true, buffer = 0 }) |
1129 nmap('ga', vim.lsp.buf.code_action, { silent = true, buffer = 0 }) | 1133 nmap('ga', vim.lsp.buf.code_action, { silent = true, buffer = 0 }) |
1130 | 1134 |
1131 if client.supports_method 'textDocument/formatting' then nmap('<c-p>', function() lsp_formatting(0) end) end | |
1132 | |
1133 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) | 1135 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
1134 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) | 1136 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
1137 | |
1138 if client.supports_method 'textDocument/rangeFormatting' then | |
1139 local root = vim.fs.find({ '.git', '.hg' }, { path = client.config.root_dir }) | |
1140 local vcs = 'git' | |
1141 if root then vcs = vim.fs.basename(root[1]):sub(2) end | |
1142 | |
1143 vim.notify('Enabled modification formatting via ' .. vcs .. ' using ' .. client.name, vim.log.levels.INFO) | |
1144 local lsp_format_modifications = require 'lsp-format-modifications' | |
1145 lsp_format_modifications.attach(client, bufnr, { format_on_save = false, vcs = 'hg' }) | |
1146 nmap('<c-p>', function() lsp_format_modifications.format_modifications_current_buffer() end) | |
1147 elseif client.supports_method 'textDocument/formatting' then | |
1148 nmap('<c-p>', function() lsp_formatting(0) end) | |
1149 end | |
1135 end | 1150 end |
1136 | 1151 |
1137 local capabilities = require('cmp_nvim_lsp').default_capabilities() | 1152 local capabilities = require('cmp_nvim_lsp').default_capabilities() |
1138 capabilities.textDocument.completion.completionItem.snippetSupport = true | 1153 capabilities.textDocument.completion.completionItem.snippetSupport = true |
1139 capabilities.textDocument.completion.completionItem.resolveSupport = { | 1154 capabilities.textDocument.completion.completionItem.resolveSupport = { |