diff options
Diffstat (limited to 'nvim/lua')
| -rw-r--r-- | nvim/lua/config/keymaps.lua | 6 | ||||
| -rw-r--r-- | nvim/lua/plugins/format.lua | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index b193d5c..29dee94 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua | |||
| @@ -15,12 +15,6 @@ function M.lsp(buffer, client) | |||
| 15 | map("n", "K", vim.lsp.buf.hover, opts) | 15 | map("n", "K", vim.lsp.buf.hover, opts) |
| 16 | map("n", "<leader>rn", vim.lsp.buf.rename, opts) | 16 | map("n", "<leader>rn", vim.lsp.buf.rename, opts) |
| 17 | map("n", "<leader>ca", vim.lsp.buf.code_action, opts) | 17 | map("n", "<leader>ca", vim.lsp.buf.code_action, opts) |
| 18 | map("n", "<leader>cf", function() | ||
| 19 | require("conform").format({ | ||
| 20 | async = true, | ||
| 21 | lsp_fallback = true, | ||
| 22 | }) | ||
| 23 | end, opts) | ||
| 24 | 18 | ||
| 25 | local function set_c_bindings() | 19 | local function set_c_bindings() |
| 26 | if client and client.name == "clangd" then map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts) end | 20 | if client and client.name == "clangd" then map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts) end |
diff --git a/nvim/lua/plugins/format.lua b/nvim/lua/plugins/format.lua index 2d6a55c..9010657 100644 --- a/nvim/lua/plugins/format.lua +++ b/nvim/lua/plugins/format.lua | |||
| @@ -1,12 +1,24 @@ | |||
| 1 | return { | 1 | return { |
| 2 | "stevearc/conform.nvim", | 2 | "stevearc/conform.nvim", |
| 3 | event = { "BufReadPre", "BufNewFile" }, | 3 | event = { "BufReadPre", "BufNewFile" }, |
| 4 | keys = { | ||
| 5 | { | ||
| 6 | "<leader>cf", | ||
| 7 | function() | ||
| 8 | require("conform").format({ | ||
| 9 | async = true, | ||
| 10 | lsp_fallback = true, | ||
| 11 | }) | ||
| 12 | end, | ||
| 13 | desc = "Format file", | ||
| 14 | }, | ||
| 15 | }, | ||
| 4 | opts = { | 16 | opts = { |
| 5 | formatters_by_ft = { | 17 | formatters_by_ft = { |
| 6 | sh = { "shfmt" }, -- brew install, pkg install shfmt | 18 | sh = { "shfmt" }, -- brew install, pkg install shfmt |
| 7 | bash = { "shfmt" }, | 19 | bash = { "shfmt" }, |
| 8 | python = { "ruff_format", "black" }, -- brew install ruff, pkg install ruff | 20 | python = { "ruff_format", "black" }, -- brew install ruff, pkg install ruff |
| 9 | lua = { "stylua" }, -- brew install stylua, pkg install stylua | 21 | lua = { "stylua" }, -- brew install stylua, pkg install stylua |
| 10 | typescript = { "prettierd", "prettier" }, | 22 | typescript = { "prettierd", "prettier" }, |
| 11 | javascript = { "prettierd", "prettier" }, | 23 | javascript = { "prettierd", "prettier" }, |
| 12 | json = { "jq" }, -- brew install jq, pkg install jq | 24 | json = { "jq" }, -- brew install jq, pkg install jq |
