mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 09:49:48 +01:00
feat: keybind to toggle format on save
This commit is contained in:
parent
d1b497e3e5
commit
d43afa4316
2 changed files with 8 additions and 0 deletions
|
@ -41,6 +41,7 @@ in {
|
||||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
||||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
||||||
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
||||||
|
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable formatting
|
-- Enable formatting
|
||||||
|
@ -56,6 +57,10 @@ in {
|
||||||
${
|
${
|
||||||
if config.vim.lsp.null-ls.enable
|
if config.vim.lsp.null-ls.enable
|
||||||
then ''
|
then ''
|
||||||
|
if vim.b.disableFormatSave then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local function is_null_ls_formatting_enabled(bufnr)
|
local function is_null_ls_formatting_enabled(bufnr)
|
||||||
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||||
local generators = require("null-ls.generators").get_available(
|
local generators = require("null-ls.generators").get_available(
|
||||||
|
|
|
@ -63,6 +63,9 @@ in {
|
||||||
format =
|
format =
|
||||||
mkMappingOption "Format"
|
mkMappingOption "Format"
|
||||||
"<leader>lf";
|
"<leader>lf";
|
||||||
|
toggleFormatOnSave =
|
||||||
|
mkMappingOption "Toggle format on save"
|
||||||
|
"<leader>ltf";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue