feat: conform.nvim for better formatting.
This commit is contained in:
parent
d8f42809ea
commit
3cc82f09dd
3 changed files with 22 additions and 0 deletions
17
lua/plugins/conform.lua
Normal file
17
lua/plugins/conform.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
vim.pack.add({
|
||||
{src = "https://github.com/stevearc/conform.nvim"},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("Format", function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
range = {
|
||||
start = { args.line1, 0 },
|
||||
["end"] = { args.line2, end_line:len() },
|
||||
}
|
||||
end
|
||||
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
||||
end, { range = true })
|
||||
|
||||
vim.keymap.set("n", "<Leader>lf", ":Format<CR>", { desc = "Format buffer with available lsp" })
|
||||
|
|
@ -3,3 +3,4 @@ require("plugins.treesitter")
|
|||
require("plugins.lsp")
|
||||
require("plugins.mini")
|
||||
require("plugins.markdown")
|
||||
require("plugins.conform")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
"plugins": {
|
||||
"conform.nvim": {
|
||||
"rev": "26c02e1",
|
||||
"src": "https://github.com/stevearc/conform.nvim"
|
||||
},
|
||||
"gruvbox.nvim": {
|
||||
"rev": "5e0a460",
|
||||
"src": "https://github.com/ellisonleao/gruvbox.nvim"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue