null-ls formatter name is different from its command (#1141)

* null-ls formatter name is different from it's command

* add more language support

* nil is unnecessary
This commit is contained in:
Abouzar Parvan 2021-07-28 19:33:49 +04:30 committed by GitHub
parent 2ec446e21e
commit 21971cbed5
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 17 deletions

1
ftplugin/asm.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "asm"

1
ftplugin/beancount.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "beancount"

1
ftplugin/crystal.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "crystal"

1
ftplugin/d.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "d"

1
ftplugin/perl.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "perl"

1
ftplugin/sql.lua Normal file
View file

@ -0,0 +1 @@
require("lsp").setup "sql"

View file

@ -212,6 +212,7 @@ local function get_attached_provider_name(msg)
for _, client in pairs(buf_clients) do
if client.name == "null-ls" then
table.insert(buf_client_names, lvim.lang[buf_ft].linters[1])
table.insert(buf_client_names, lvim.lang[buf_ft].formatter.exe)
else
table.insert(buf_client_names, client.name)
end

View file

@ -66,6 +66,32 @@ end
-- TODO move all of this into lang specific files, only require when using
lvim.lang = {
asm = {
formatter = {
exe = "asmfmt",
args = {},
},
linters = {},
lsp = {
provider = "",
setup = {},
},
},
beancount = {
formatter = {
exe = "bean_format",
args = {},
},
linters = {},
lsp = {
provider = "beancount",
setup = {
cmd = { "beancount-langserver" },
on_attach = common_on_attach,
capabilities = common_capabilities,
},
},
},
c = {
formatter = {
exe = "clang_format",
@ -117,9 +143,24 @@ lvim.lang = {
},
},
},
crystal = {
formatter = {
exe = "crystal_format",
args = {},
},
linters = {},
lsp = {
provider = "crystalline",
setup = {
cmd = { "crystalline" },
on_attach = common_on_attach,
capabilities = common_capabilities,
},
},
},
cs = {
formatter = {
exe = "",
exe = "clang_format",
args = {},
},
linters = {},
@ -139,7 +180,7 @@ lvim.lang = {
},
cmake = {
formatter = {
exe = "clang_format",
exe = "cmake_format",
args = {},
},
linters = {},
@ -192,10 +233,25 @@ lvim.lang = {
},
},
},
d = {
formatter = {
exe = "dfmt",
args = {},
},
linters = {},
lsp = {
provider = "serve_d",
setup = {
cmd = { "serve-d" },
on_attach = common_on_attach,
capabilities = common_capabilities,
},
},
},
dart = {
formatter = {
exe = "dart",
args = { "format" },
exe = "dart_format",
args = {},
stdin = true,
},
linters = {},
@ -233,7 +289,7 @@ lvim.lang = {
elixir = {
formatter = {
exe = "mix",
args = { "format" },
args = {},
stdin = true,
},
linters = {},
@ -250,7 +306,7 @@ lvim.lang = {
},
elm = {
formatter = {
exe = "",
exe = "elm_format",
args = {},
stdin = true,
},
@ -273,7 +329,7 @@ lvim.lang = {
},
erlang = {
formatter = {
exe = "",
exe = "erlfmt",
args = {},
},
linters = {},
@ -291,7 +347,7 @@ lvim.lang = {
emmet = { active = false },
fish = {
formatter = {
exe = "",
exe = "fish_indent",
args = {},
},
linters = {},
@ -384,8 +440,8 @@ lvim.lang = {
},
json = {
formatter = {
exe = "python",
args = { "-m", "json.tool" },
exe = "json_tool",
args = {},
stdin = true,
},
linters = {},
@ -515,10 +571,45 @@ lvim.lang = {
},
},
},
nginx = {
formatter = {
exe = "nginx_beautifier",
args = {
provider = "",
setup = {},
},
},
linters = {},
lsp = {},
},
perl = {
formatter = {
exe = "perltidy",
args = {},
},
linters = {},
lsp = {
provider = "",
setup = {},
},
},
sql = {
formatter = {
exe = "sqlformat",
args = {},
},
linters = {},
lsp = {
provider = "sqls",
setup = {
cmd = { "sqls" },
},
},
},
php = {
formatter = {
exe = "phpcbf",
args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) },
args = {},
},
linters = {},
lsp = {
@ -625,7 +716,7 @@ lvim.lang = {
-- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")'
r = {
formatter = {
exe = "",
exe = "format_r",
args = {},
},
linters = {},
@ -663,7 +754,7 @@ lvim.lang = {
},
rust = {
formatter = {
exe = "",
exe = "rustfmt",
args = {},
},
linters = {},
@ -680,7 +771,7 @@ lvim.lang = {
},
scala = {
formatter = {
exe = "",
exe = "scalafmt",
args = {},
},
linters = { "" },
@ -762,9 +853,8 @@ lvim.lang = {
},
terraform = {
formatter = {
exe = "",
exe = "terraform_fmt",
args = {},
stdin = false,
},
linters = {},
lsp = {

View file

@ -43,7 +43,7 @@ local function setup_ls(exe, type)
end
end
else
if vim.fn.executable(exe) == 1 then
if null_ls.builtins[type][exe] and vim.fn.executable(null_ls.builtins[type][exe]._opts.command) then
table.insert(sources, null_ls.builtins[type][exe])
end
end