added conform

This commit is contained in:
2024-02-08 14:54:22 +01:00
parent 48d934c361
commit 0d028910ce
4 changed files with 31 additions and 1 deletions

22
after/plugin/conform.lua Normal file
View File

@@ -0,0 +1,22 @@
local conform = require("conform")
conform.setup({
formatters_by_ft = {
lua = { "stylua" },
c = { "clang_format" },
cs = { "csharpier" },
javascript = { { "prettierd", "prettier" } },
rust = { "rustfmt" },
},
})
conform.formatters.clang_format = {
args = { "--style", "{IndentWidth: 4, UseTab: Always, TabWidth: 4}" },
}
conform.formatters.rustfmt = {
args = { "--edition", "2021" },
}
vim.keymap.set("n", "<leader>f", function()
conform.format({ bufnr = vim.lsp.bufnr })
end)

View File

@@ -72,4 +72,8 @@ return require('packer').startup(function(use)
'folke/trouble.nvim', 'folke/trouble.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' } dependencies = { 'nvim-tree/nvim-web-devicons' }
} }
use({
'stevearc/conform.nvim'
})
end) end)

View File

@@ -24,7 +24,6 @@ vim.keymap.set("i", "<C-c>", "<Esc>")
vim.keymap.set("n", "Q", "<nop>") vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>") vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
-- vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz") -- vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
-- vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz") -- vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")

View File

@@ -114,6 +114,11 @@ _G.packer_plugins = {
path = "/home/j409/.local/share/nvim/site/pack/packer/start/cmp-path", path = "/home/j409/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path" url = "https://github.com/hrsh7th/cmp-path"
}, },
["conform.nvim"] = {
loaded = true,
path = "/home/j409/.local/share/nvim/site/pack/packer/start/conform.nvim",
url = "https://github.com/stevearc/conform.nvim"
},
harpoon = { harpoon = {
loaded = true, loaded = true,
path = "/home/j409/.local/share/nvim/site/pack/packer/start/harpoon", path = "/home/j409/.local/share/nvim/site/pack/packer/start/harpoon",