pkgs(nixvim): Add some language supports for formatting
This commit is contained in:
parent
37914d6957
commit
d242144445
10 changed files with 352 additions and 0 deletions
31
pkgs/nixvim/lang/c/formatting.nix
Normal file
31
pkgs/nixvim/lang/c/formatting.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.c = {
|
||||
__unkeyed-1 = "clang-format";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters.clang-format = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.clang-format")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("clang-format")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe' pkgs.clang-tools "clang-format"}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
31
pkgs/nixvim/lang/cxx/formatting.nix
Normal file
31
pkgs/nixvim/lang/cxx/formatting.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.cpp = {
|
||||
__unkeyed-1 = "clang-format";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters.clang-format = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.clang-format")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("clang-format")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe' pkgs.clang-tools "clang-format"}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
30
pkgs/nixvim/lang/json/formatting.nix
Normal file
30
pkgs/nixvim/lang/json/formatting.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.json = {
|
||||
__unkeyed-1 = "deno_fmt";
|
||||
};
|
||||
formatters.deno_fmt = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.deno_fmt")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("deno")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.deno}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
31
pkgs/nixvim/lang/lua/formatting.nix
Normal file
31
pkgs/nixvim/lang/lua/formatting.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.lua = {
|
||||
__unkeyed-1 = "stylua";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters.stylua = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.stylua")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("stylua")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.stylua}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
30
pkgs/nixvim/lang/markdown/formatting.nix
Normal file
30
pkgs/nixvim/lang/markdown/formatting.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.markdown = {
|
||||
__unkeyed-1 = "deno_fmt";
|
||||
};
|
||||
formatters.deno_fmt = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.deno_fmt")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("deno")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.deno}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
53
pkgs/nixvim/lang/nix/formatting.nix
Normal file
53
pkgs/nixvim/lang/nix/formatting.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.nix = {
|
||||
__unkeyed-1 = "alejandra";
|
||||
__unkeyed-2 = "injected";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters = {
|
||||
alejandra = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.alejandra")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("alejandra")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.alejandra}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
nixfmt = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.nixfmt")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("nixfmt")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.nixfmt-rfc-style}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
53
pkgs/nixvim/lang/python/formatting.nix
Normal file
53
pkgs/nixvim/lang/python/formatting.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.python = {
|
||||
__unkeyed-1 = "ruff_format";
|
||||
__unkeyed-2 = "ruff_organize_imports";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters = {
|
||||
ruff_organize_imports = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.ruff_organize_imports")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("ruff")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.ruff}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
ruff_format = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.ruff_format")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("ruff")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.ruff}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
31
pkgs/nixvim/lang/rust/formatting.nix
Normal file
31
pkgs/nixvim/lang/rust/formatting.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.rust = {
|
||||
__unkeyed-1 = "rustfmt";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters.rustfmt = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.rustfmt")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("rustfmt")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.rustfmt}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
32
pkgs/nixvim/lang/toml/formatting.nix
Normal file
32
pkgs/nixvim/lang/toml/formatting.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.toml = {
|
||||
__unkeyed-1 = "taplo";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
formatters.taplo = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.taplo")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("taplo")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.taplo}"
|
||||
end
|
||||
end,
|
||||
args = { "format", "-o", "reorder_keys=true", "-o", "reorder_inline_tables=true", "-o", "reorder_arrays=true", "-" },
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
30
pkgs/nixvim/lang/yaml/formatting.nix
Normal file
30
pkgs/nixvim/lang/yaml/formatting.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
plugins.conform-nvim.settings = {
|
||||
formatters_by_ft.yaml = {
|
||||
__unkeyed-1 = "deno_fmt";
|
||||
};
|
||||
formatters.deno_fmt = {
|
||||
__raw =
|
||||
#lua
|
||||
''
|
||||
function()
|
||||
local defaultFormatter = require("conform.formatters.deno_fmt")
|
||||
return vim.tbl_extend("force", defaultFormatter, {
|
||||
command = function()
|
||||
local exe = vim.fn["exepath"]("deno")
|
||||
if exe ~= "" then
|
||||
return exe
|
||||
else
|
||||
return "${lib.getExe pkgs.deno}"
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue