diff --git a/nvim/after/ftplugin/lua.lua b/nvim/after/ftplugin/lua.lua index 641f28199..79afbfdf0 100644 --- a/nvim/after/ftplugin/lua.lua +++ b/nvim/after/ftplugin/lua.lua @@ -1,10 +1,5 @@ -- Tabs should have 4 space width. vim.opt_local.tabstop = 4 --- Use stylua as formatter if it is available. -if vim.fn.executable("stylua") == 1 then - vim.opt_local.formatprg = "stylua --stdin-filepath % --search-parent-directories -" -end - -- Use luacheck as compiler for sh files. vim.cmd([[compiler luacheck]]) diff --git a/nvim/after/plugin/conform.lua b/nvim/after/plugin/conform.lua new file mode 100644 index 000000000..645d06b45 --- /dev/null +++ b/nvim/after/plugin/conform.lua @@ -0,0 +1,7 @@ +local options = { + formatters_by_ft = { + lua = { "stylua" }, + }, +} + +require("conform").setup(options) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua index a6aebfae4..a7570f065 100644 --- a/nvim/after/plugin/lsp.lua +++ b/nvim/after/plugin/lsp.lua @@ -65,8 +65,5 @@ vim.api.nvim_create_autocmd("LspAttach", { vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "f", function() - vim.lsp.buf.format({ async = true }) - end, opts) end, }) diff --git a/nvim/lua/dcp/keymaps.lua b/nvim/lua/dcp/keymaps.lua index b6c02524a..7d69fe0c9 100644 --- a/nvim/lua/dcp/keymaps.lua +++ b/nvim/lua/dcp/keymaps.lua @@ -22,6 +22,13 @@ vim.g.mapleader = "\\" vim.g.maplocalleader = " " +-- Leader,a series acts on the whole file. +-- +-- Leader,ai indents the whole file. +vim.keymap.set("n", "ai", "mzgg=G`z") +-- Leader,af formats the whole file. +vim.keymap.set("n", "af", "mzgggqG`z") + -- Leader,b list all open buffers. vim.keymap.set("n", "b", ":buffer ")