Skip to content

Commit

Permalink
fix: some config
Browse files Browse the repository at this point in the history
  • Loading branch information
misumisumi committed Jun 3, 2024
1 parent 60ef0e1 commit 9aaddc3
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 100 deletions.
133 changes: 69 additions & 64 deletions lua/user/configs/exception.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,74 @@ M.is_nixos = function()
return vim.fn.filewritable("/etc/NIXOS")
end

M.null_ls = {
commitlint = function()
return require("null-ls.builtins").diagnostics.commitlint.with({
extra_args = function()
local utils = require("null-ls.utils").make_conditional_utils()
if
utils.root_has_file({
".commitlintrc",
".commitlintrc.json",
".commitlintrc.yaml",
".commitlintrc.yml",
".commitlintrc.js",
".commitlintrc.cjs",
".commitlintrc.mjs",
".commitlintrc.ts",
".commitlintrc.cts",
"commitlint.config.js",
"commitlint.config.cjs",
"commitlint.config.mjs",
"commitlint.config.ts",
"commitlint.config.cts",
})
then
return {}
else
local home = require("core.global").home
return {
"-g",
home .. "/.config/git/.commitlintrc.json",
}
end
end,
})
end,
textlint = function()
return require("null-ls.builtins").diagnostics.textlint.with({
condition = function(utils)
if
utils.root_has_file({
".textlintrc",
".textlintrc.js",
".textlintrc.json",
".textlintrc.yml",
".textlintrc.yaml",
})
then
vim.api.nvim_create_user_command("TextlintFix", function()
if vim.fn.executable("textlint") == 1 then
vim.cmd("silent !textlint --fix %")
else
vim.cmd("silent !npx textlint --fix %")
end
vim.notify(
string.format("textlint successfully!"),
vim.log.levels.INFO,
{ title = "Format Success" }
)
end, {})
return true
end
end,
})
end,
}
M.null_ls = function()
local btns = require("null-ls.builtins")
return {
commitlint = {
diagnostics = btns.diagnostics.commitlint.with({
extra_args = function()
local utils = require("null-ls.utils").make_conditional_utils()
if
utils.root_has_file({
".commitlintrc",
".commitlintrc.json",
".commitlintrc.yaml",
".commitlintrc.yml",
".commitlintrc.js",
".commitlintrc.cjs",
".commitlintrc.mjs",
".commitlintrc.ts",
".commitlintrc.cts",
"commitlint.config.js",
"commitlint.config.cjs",
"commitlint.config.mjs",
"commitlint.config.ts",
"commitlint.config.cts",
})
then
return {}
else
local home = require("core.global").home
return {
"-g",
home .. "/.config/git/.commitlintrc.json",
}
end
end,
}),
},
textlint = {
diagnostics = btns.diagnostics.textlint.with({
filetypes = { "markdown", "txt", "tex" },
timeout = 15000,
condition = function(utils)
if
utils.root_has_file({
".textlintrc",
".textlintrc.js",
".textlintrc.json",
".textlintrc.yml",
".textlintrc.yaml",
})
then
vim.api.nvim_create_user_command("TextlintFix", function()
if vim.fn.executable("textlint") == 1 then
vim.cmd("silent !textlint --fix %")
else
vim.cmd("silent !npx textlint --fix %")
end
vim.notify(
string.format("textlint successfully!"),
vim.log.levels.INFO,
{ title = "Format Success" }
)
end, {})
return true
end
end,
}),
},
}
end

return M
31 changes: 31 additions & 0 deletions lua/user/configs/lsp-servers/texlab.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
return {
cmd = { "texlab" },
filetypes = { "tex", "plaintex", "bib" },
settings = {
{
texlab = {
auxDirectory = ".",
bibtexFormatter = "texlab",
build = {
args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
executable = "latexmk",
forwardSearchAfter = false,
onSave = false,
},
chktex = {
onEdit = false,
onOpenAndSave = false,
},
diagnosticsDelay = 300,
formatterLineLength = 80,
forwardSearch = {
args = {},
},
latexFormatter = "latexindent",
latexindent = {
modifyLineBreaks = false,
},
},
},
},
}
68 changes: 46 additions & 22 deletions lua/user/configs/mason-null-ls.lua
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
local null_ls = require("null-ls")
local btns = null_ls.builtins
local exception = require("user.configs.exception")
local handlers = {
actionlint = function()
null_ls.register(btns.diagnostics.actionlint.with({
condition = function()
return vim.fn.fnamemodify(vim.fn.expand("%:p:h"), ":t") == "workflows"
end,
}))
end,
}

if not exception.is_nixos() then
for k, setup in pairs(exception.null_ls) do
handlers[k] = null_ls.register(setup())
return function()
local null_ls = require("null-ls")
local btns = null_ls.builtins
local exception = require("user.configs.exception")
local handlers = {
actionlint = function()
null_ls.register(btns.diagnostics.actionlint.with({
condition = function()
return vim.fn.fnamemodify(vim.fn.expand("%:p:h"), ":t") == "workflows"
end,
}))
end,
prettier = function()
null_ls.register(btns.formatting.prettier.with({
-- filetypes = { "markdown", "txt", "tex" },
condition = function(utils)
if
utils.root_has_file({
".textlintrc",
".textlintrc.js",
".textlintrc.json",
".textlintrc.yml",
".textlintrc.yaml",
})
then
return false
end
end,
}))
end,
}
if exception.is_nixos() then
-- for tool, _ in pairs(exception.null_ls()) do
-- handlers[tool] = function() end
-- end
else
for tool, setups in pairs(exception.null_ls()) do
handlers[tool] = function()
for _, setup in pairs(setups) do
null_ls.register(setup)
end
end
end
end
return {
handlers = handlers,
}
end

return {
handlers = function()
return handlers
end,
}
30 changes: 17 additions & 13 deletions lua/user/configs/null-ls.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
local null_ls = require("null-ls")
local btns = null_ls.builtins
local sources = {
btns.diagnostics.statix,
}
local exception = require("user.configs.exception")
if exception.is_nixos() then
for _, setup in pairs(exception.null_ls) do
table.insert(sources, setup())
return function()
local null_ls = require("null-ls")
local btns = null_ls.builtins
local sources = {
btns.diagnostics.statix,
}
local exception = require("user.configs.exception")
if exception.is_nixos() then
for _, setups in pairs(exception.null_ls()) do
for _, setup in pairs(setups) do
table.insert(sources, setup)
end
end
end
return {
sources = sources,
debug = true,
}
end

return {
sources = sources,
}
3 changes: 3 additions & 0 deletions lua/user/configs/project_nvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
patterns = { "*.tex", "default.yaml", ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },
}
1 change: 1 addition & 0 deletions lua/user/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local options = {
-- Example
autoindent = true,
colorcolumn = "80,100",
-- fileencodings = "iso-2022-jp,euc-jp,sjis,utf-8",
}

return options
2 changes: 1 addition & 1 deletion lua/user/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local null_ls_deps = {
"actionlint",
}
if not exception.is_nixos() then
for k, _ in pairs(exception.null_ls) do
for k, _ in pairs(exception.null_ls()) do
table.insert(null_ls_deps, k)
end
end
Expand Down

0 comments on commit 9aaddc3

Please sign in to comment.