Default config reformat (#951)

This commit is contained in:
Abouzar Parvan 2021-07-15 05:44:25 +04:30 committed by GitHub
parent 7f11162bd8
commit f95e150518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 233 additions and 313 deletions

View file

@ -85,196 +85,8 @@ O = {
-- TODO move all of this into lang specific files, only require when using
lang = {
cmake = {
formatter = {
exe = "clang-format",
args = {},
},
},
css = {
virtual_text = true,
formatter = {
exe = "prettier",
args = {},
},
},
dart = {
sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
formatter = {
exe = "dart",
args = { "format" },
},
},
docker = {},
efm = {},
elm = {},
emmet = { active = false },
elixir = {
formatter = {
exe = "mix",
args = { "format" },
stdin = true,
},
},
graphql = {},
go = {
formatter = {
exe = "gofmt",
args = {},
},
},
html = {},
java = {
java_tools = {
active = false,
},
formatter = {
exe = "prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
},
},
json = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "python",
args = { "-m", "json.tool" },
},
},
kotlin = {},
latex = {
filetypes = { "tex", "bib"},
aux_directory = nil,
bibtex_formatter = "texlab",
diagnostics_delay = 300,
formatter_line_length = 80,
latex_formatter = "latexindent",
build = {
executable = "latexmk",
args = {'-pdf', '-interaction=nonstopmode', '-synctex=1', '%f'},
on_save = false,
forward_search_after = false,
},
chktex = {
on_open_and_save = false,
on_edit = false,
},
forward_search = {
executable = nil,
args = {}
},
latexindent = {
["local"] = nil,
modify_line_breaks = false
},
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true,
},
auto_save = false,
ignore_errors = {},
},
lua = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "stylua",
args = {},
stdin = false,
},
},
php = {
format = {
format = {
default = "psr12",
},
},
environment = {
php_version = "7.4",
},
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
filetypes = { "php", "phtml" },
formatter = {
exe = "phpcbf",
args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) },
stdin = false,
},
},
python = {
-- @usage can be flake8 or yapf
linter = "",
isort = false,
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
analysis = {
type_checking = "basic",
auto_search_paths = true,
use_library_code_types = true,
},
formatter = {
exe = "yapf",
args = {},
},
},
ruby = {
diagnostics = {
virtualtext = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
filetypes = { "rb", "erb", "rakefile", "ruby" },
formatter = {
exe = "rufo",
args = { "-x" },
},
},
rust = {
rust_tools = {
active = false,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>", -- prefix for all the other hints (type, chaining)
},
-- @usage can be clippy
formatter = {
exe = "rustfmt",
args = { "--emit=stdout", "--edition=2018" },
},
linter = "",
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
},
sh = {
-- @usage can be 'shellcheck'
linter = "",
-- @usage can be 'shfmt'
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "shfmt",
args = { "-w" },
stdin = false,
},
},
svelte = {},
tailwindcss = {
active = false,
@ -288,13 +100,6 @@ O = {
"typescriptreact",
},
},
terraform = {
formatter = {
exe = "terraform",
args = { "fmt" },
stdin = false,
},
},
tsserver = {
-- @usage can be 'eslint' or 'eslint_d'
linter = "",
@ -308,13 +113,6 @@ O = {
args = {},
},
},
vim = {},
yaml = {
formatter = {
exe = "prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
},
},
},
}
@ -330,3 +128,25 @@ require("core.treesitter").config()
require("core.which-key").config()
require("lang.clang").config()
require("lang.cmake").config()
require("lang.css").config()
require("lang.dart").config()
require("lang.dockerfile").config()
require("lang.elixir").config()
require("lang.elm").config()
require("lang.go").config()
require("lang.graphql").config()
require("lang.html").config()
require("lang.java").config()
require("lang.json").config()
require("lang.kotlin").config()
require("lang.lua").config()
require("lang.php").config()
require("lang.python").config()
require("lang.ruby").config()
require("lang.rust").config()
require("lang.sh").config()
require("lang.terraform").config()
require("lang.tex").config()
require("lang.vim").config()
require("lang.yaml").config()

View file

@ -1,63 +0,0 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
end
M.format = function()
O.formatters.filetype["c"] = {
function()
return {
exe = O.lang.clang.formatter.exe,
args = O.lang.clang.formatter.args,
stdin = not (O.lang.clang.formatter.stdin ~= nil),
}
end,
}
O.formatters.filetype["cpp"] = O.formatters.filetype["c"]
require("formatter.config").set_defaults {
logging = false,
filetype = O.formatters.filetype,
}
end
M.lint = function()
-- TODO: implement linters (if applicable)
return "No linters configured!"
end
M.lsp = function()
if require("lv-utils").check_lsp_client_active "clangd" then
return
end
local clangd_flags = { "--background-index" }
if O.lang.clang.cross_file_rename then
table.insert(clangd_flags, "--cross-file-rename")
end
table.insert(clangd_flags, "--header-insertion=" .. O.lang.clang.header_insertion)
require("lspconfig").clangd.setup {
cmd = { DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", unpack(clangd_flags) },
on_attach = require("lsp").common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.lang.clang.diagnostics.virtual_text,
signs = O.lang.clang.diagnostics.signs,
underline = O.lang.clang.diagnostics.underline,
update_in_insert = true,
}),
},
}
end
M.dap = function()
-- TODO: implement dap
return "No DAP configured!"
end
return M

View file

@ -1,8 +1,12 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.cmake = {
formatter = {
exe = "clang-format",
args = {},
},
}
end
M.format = function()

View file

@ -1,8 +1,13 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.css = {
virtual_text = true,
formatter = {
exe = "prettier",
args = {},
},
}
end
M.format = function()

View file

@ -1,8 +1,13 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.dart = {
sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
formatter = {
exe = "dart",
args = { "format" },
},
}
end
M.format = function()

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.docker = {}
end
M.format = function()

View file

@ -1,8 +1,13 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.elixir = {
formatter = {
exe = "mix",
args = { "format" },
stdin = true,
},
}
end
M.format = function()

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.elm = {}
end
M.format = function()

View file

@ -1,6 +1,15 @@
local M = {}
M.config = function()
O.lang.go = {
formatter = {
exe = "gofmt",
args = {},
},
}
end
M.format = function()
O.formatters.filetype["go"] = {
function()
return {
@ -17,11 +26,6 @@ M.config = function()
}
end
M.format = function()
-- TODO: implement formatter for language
return "No formatter available!"
end
M.lint = function()
-- TODO: implement linters (if applicable)
return "No linters configured!"

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.graphql = {}
end
M.format = function()

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.html = {}
end
M.format = function()

View file

@ -1,8 +1,15 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.java = {
java_tools = {
active = false,
},
formatter = {
exe = "prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
},
}
end
M.format = function()

View file

@ -1,8 +1,17 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.json = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "python",
args = { "-m", "json.tool" },
},
}
end
M.format = function()

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.kotlin = {}
end
M.format = function()

View file

@ -1,8 +1,18 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.lua = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "stylua",
args = {},
stdin = false,
},
}
end
M.format = function()

View file

@ -1,8 +1,27 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.php = {
format = {
format = {
default = "psr12",
},
},
environment = {
php_version = "7.4",
},
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
filetypes = { "php", "phtml" },
formatter = {
exe = "phpcbf",
args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) },
stdin = false,
},
}
end
M.format = function()

View file

@ -1,5 +1,27 @@
local M = {}
M.config = function()
O.lang.python = {
-- @usage can be flake8 or yapf
linter = "",
isort = false,
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
analysis = {
type_checking = "basic",
auto_search_paths = true,
use_library_code_types = true,
},
formatter = {
exe = "yapf",
args = {},
},
}
end
M.format = function()
O.formatters.filetype["python"] = {
function()

View file

@ -1,8 +1,18 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.ruby = {
diagnostics = {
virtualtext = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
filetypes = { "rb", "erb", "rakefile", "ruby" },
formatter = {
exe = "rufo",
args = { "-x" },
},
}
end
M.format = function()

View file

@ -1,8 +1,24 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.rust = {
rust_tools = {
active = false,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>", -- prefix for all the other hints (type, chaining)
},
-- @usage can be clippy
formatter = {
exe = "rustfmt",
args = { "--emit=stdout", "--edition=2018" },
},
linter = "",
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
}
end
M.format = function()

View file

@ -1,8 +1,21 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.sh = {
-- @usage can be 'shellcheck'
linter = "",
-- @usage can be 'shfmt'
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
formatter = {
exe = "shfmt",
args = { "-w" },
stdin = false,
},
}
end
M.format = function()

View file

@ -1,8 +1,13 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.terraform = {
formatter = {
exe = "terraform",
args = { "fmt" },
stdin = false,
},
}
end
M.format = function()

View file

@ -1,8 +1,39 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.latex = {
filetypes = { "tex", "bib" },
aux_directory = nil,
bibtex_formatter = "texlab",
diagnostics_delay = 300,
formatter_line_length = 80,
latex_formatter = "latexindent",
build = {
executable = "latexmk",
args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
on_save = false,
forward_search_after = false,
},
chktex = {
on_open_and_save = false,
on_edit = false,
},
forward_search = {
executable = nil,
args = {},
},
latexindent = {
["local"] = nil,
modify_line_breaks = false,
},
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
auto_save = false,
ignore_errors = {},
}
end
M.format = function()

View file

@ -1,8 +1,7 @@
local M = {}
M.config = function()
-- TODO: implement config for language
return "No config available!"
O.lang.vim = {}
end
M.format = function()

View file

@ -1,6 +1,15 @@
local M = {}
M.config = function()
O.lang.yaml = {
formatter = {
exe = "prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
},
}
end
M.format = function()
O.formatters.filetype["yaml"] = {
function()
return {
@ -16,11 +25,6 @@ M.config = function()
}
end
M.format = function()
-- TODO: implement formatter for language
return "No formatter available!"
end
M.lint = function()
-- TODO: implement linters (if applicable)
return "No linters configured!"