Add conform plugin
This commit is contained in:
parent
415f123c45
commit
3cf5918261
42
modules/home-manager/nixvim/plugins/conform.nix
Normal file
42
modules/home-manager/nixvim/plugins/conform.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
extraPackages = with pkgs; [
|
||||
stylua
|
||||
];
|
||||
|
||||
plugins.conform-nvim = {
|
||||
enable = true;
|
||||
notifyOnError = false;
|
||||
formatOnSave = ''
|
||||
function(bufnr)
|
||||
local disable_filetypes = { c = true, cpp = true }
|
||||
return {
|
||||
timeout_ms = 500
|
||||
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype]
|
||||
}
|
||||
end
|
||||
'';
|
||||
|
||||
formattersByFt = {
|
||||
lua = ["stylua"];
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = [
|
||||
{
|
||||
mode = "";
|
||||
key = "<leader>f";
|
||||
action.__raw = ''
|
||||
function()
|
||||
require('conform').format { async = true, lsp_fallback = true }
|
||||
end
|
||||
'';
|
||||
options = {
|
||||
desc = "[F]ormat buffer";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user