diff options
-rw-r--r-- | init.vim | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 |