diff --git a/lua/config/keybindings.lua b/lua/config/keybindings.lua index 69cf573..fffaa86 100644 --- a/lua/config/keybindings.lua +++ b/lua/config/keybindings.lua @@ -5,8 +5,8 @@ vim.g.maplocalleader = ";" -- source current file vim.keymap.set("n", " ", ":update :source", { desc = "Source current lua file" }) --- format -vim.keymap.set("n", "lf", vim.lsp.buf.format, { desc = "Format buffer with available lsp" }) +-- -- format +-- vim.keymap.set("n", "lf", vim.lsp.buf.format, { desc = "Format buffer with available lsp" }) -- easy copy/cut/paste from system clipboard vim.keymap.set({ "n", "v", "x" }, "y", '"+y', { desc = "Yank to system clipboard" }) diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 0000000..be4fe0d --- /dev/null +++ b/lua/plugins/conform.lua @@ -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", "lf", ":Format", { desc = "Format buffer with available lsp" }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 22ace95..c9dd8b6 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -3,3 +3,4 @@ require("plugins.treesitter") require("plugins.lsp") require("plugins.mini") require("plugins.markdown") +require("plugins.conform") diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index d485b2d..562856b 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -21,8 +21,12 @@ vim.lsp.enable({ "nixd", "lua_ls", "jsonls", + "html", "marksman", "gopls", + "ruff", + "basedpyright", + "yamlls", }) -- diagnostic settings diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index fbddbc6..f78e0bc 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -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"