summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.vim11
1 files changed, 10 insertions, 1 deletions
diff --git a/init.vim b/init.vim
index 381a3a9..a91c4cd 100644
--- a/init.vim
+++ b/init.vim
@@ -86,7 +86,7 @@ noremap <C-w><C-S-t> <C-w>s<cmd>TERM<cr>
noremap Y y$
" Format code. This is <AltGr-u>
-noremap ú <cmd>FormatCode<cr>
+noremap ú <cmd>lua run_format_code()<cr>
" Synstack to help profile syntax highlighting issues.
noremap <leader>p <plug>(SynStack)
@@ -317,5 +317,14 @@ lua << EOF
})
vim.fn.HighlightColorColumns()
+ function run_format_code()
+ local lsps = vim.lsp.buf_get_clients()
+ if lsps and #lsps > 0 then
+ vim.lsp.buf.format()
+ else
+ vim.cmd("FormatCode")
+ end
+ end
+
EOF