Merge pull request #156 from horriblename/feat-disable-autoformat

feat: allow disabling format on save per buffer
This commit is contained in:
raf 2023-10-23 20:22:01 +03:00 committed by GitHub
commit 2b48b6d844
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View file

@ -22,6 +22,8 @@ https://github.com/horriblename[horriblename]:
* Add lua LSP and treesitter support, and neodev.nvim plugin support
* Add <<opt-vim.lsp.mappings.toggleFormatOnSave>> keybind
https://github.com/amanse[amanse]:
* Added daily notes options for obsidian plugin

View file

@ -41,6 +41,7 @@ in {
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
${mkBinding mappings.format "vim.lsp.buf.format()"}
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
end
-- Enable formatting
@ -56,6 +57,10 @@ in {
${
if config.vim.lsp.null-ls.enable
then ''
if vim.b.disableFormatSave then
return
end
local function is_null_ls_formatting_enabled(bufnr)
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
local generators = require("null-ls.generators").get_available(

View file

@ -63,6 +63,9 @@ in {
format =
mkMappingOption "Format"
"<leader>lf";
toggleFormatOnSave =
mkMappingOption "Toggle format on save"
"<leader>ltf";
};
};
}