Skip to content

Commit

Permalink
feat(lsp): added opts.autoformat to be able to disable autoformat b…
Browse files Browse the repository at this point in the history
…y default. Fixes #65
  • Loading branch information
folke committed Jan 16, 2023
1 parent 30b7215 commit b278b06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lua/lazyvim/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ local Util = require("lazyvim.util")
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })

-- FIXME: document all keymaps

-- Move to window using the <ctrl> hjkl keys
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
Expand Down
5 changes: 5 additions & 0 deletions lua/lazyvim/plugins/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ return {
virtual_text = { spacing = 4, prefix = "" },
severity_sort = true,
},
-- Automatically format on save
autoformat = true,
-- options for vim.lsp.buf.format
-- `bufnr` and `filter` is handled by the LazyVim formatter,
-- but can be also overriden when specified
Expand Down Expand Up @@ -64,6 +66,9 @@ return {
require("lazyvim.util").deprecate("lspconfig.setup_server", "lspconfig.opts.setup[SERVER]")
end

-- setup autoformat
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat

-- setup formatting and keymaps
require("lazyvim.util").on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
Expand Down

0 comments on commit b278b06

Please sign in to comment.