Skip to content

Commit

Permalink
feat: Update setting for conform.nvim
Browse files Browse the repository at this point in the history
- Target:
  The file `conform.lua` need be changed to use formatter.

- Changed
  - Update the setting to use code formatter for the plugin `conform.nvim`.
  - Add the shortcut for formatting code.
  • Loading branch information
burstknight committed Jul 8, 2024
1 parent 6aaa083 commit b4ae011
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions nvim/lua/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pluginKeys.lspKeyBinding = function(mapbuf)
mapbuf("n", "<leader>gf", ":Lspsaga finder def+ref+imp<CR>", opts)
mapbuf("n", "<F3>", ":Lspsaga outline<CR>", opts)
mapbuf("n", "<leader>h", "<cmd>Lspsaga hover_doc<CR>", opts)
mapbuf("n", "<leader>=", ":lua vim.lsp.buf.format {async = true}<CR>", opts)
end

pluginKeys.cmpKeys = function(cmp)
Expand Down
11 changes: 10 additions & 1 deletion nvim/lua/lsp/conform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ if not status then
return
end

conform.setup({})
conform.setup({
formatters_by_ft = {
lua = {"stylua"},
cpp = {"clangd-format"},
c = {"clangd-format"},
},
format_on_save = false,
})

vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"

0 comments on commit b4ae011

Please sign in to comment.