Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 782:31605398117a
fix: handle opening files not under vcs
author | zegervdv <zegervdv@me.com> |
---|---|
date | Fri, 28 Apr 2023 07:12:49 +0200 |
parents | 405ff835995a |
children | 335b1f5c242d |
comparison
equal
deleted
inserted
replaced
781:f8f28675afe7 | 782:31605398117a |
---|---|
1192 end | 1192 end |
1193 | 1193 |
1194 if client.supports_method 'textDocument/rangeFormatting' then | 1194 if client.supports_method 'textDocument/rangeFormatting' then |
1195 local root = vim.fs.find({ '.git', '.hg' }, { path = client.config.root_dir }) | 1195 local root = vim.fs.find({ '.git', '.hg' }, { path = client.config.root_dir }) |
1196 local vcs = 'git' | 1196 local vcs = 'git' |
1197 if root then vcs = vim.fs.basename(root[1]):sub(2) end | 1197 if root and #root > 0 then vcs = vim.fs.basename(root[1]):sub(2) end |
1198 | 1198 |
1199 vim.notify('Enabled modification formatting via ' .. vcs .. ' using ' .. client.name, vim.log.levels.INFO) | 1199 vim.notify('Enabled modification formatting via ' .. vcs .. ' using ' .. client.name, vim.log.levels.INFO) |
1200 local lsp_format_modifications = require 'lsp-format-modifications' | 1200 local lsp_format_modifications = require 'lsp-format-modifications' |
1201 lsp_format_modifications.attach(client, bufnr, { format_on_save = false, vcs = vcs }) | 1201 lsp_format_modifications.attach(client, bufnr, { format_on_save = false, vcs = vcs }) |
1202 nmap('<c-p>', function() lsp_format_modifications.format_modifications_current_buffer() end, opts) | 1202 nmap('<c-p>', function() lsp_format_modifications.format_modifications_current_buffer() end, opts) |