mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-29 22:29:57 +02:00
refactor: auto-generate language configuration (#1584)
Refactor the monolithic `lvim.lang` design into a more modular approach. IMPORTANT: run `:LvimUpdate` in order to generate the new ftplugin template files.
This commit is contained in:
parent
3e1cd1ec23
commit
d01ba08eae
98 changed files with 1127 additions and 1567 deletions
|
@ -1,44 +1,26 @@
|
|||
local M = {}
|
||||
|
||||
function M.list_supported_provider_names(filetype)
|
||||
local names = {}
|
||||
local Log = require "core.log"
|
||||
local formatters = require "lsp.null-ls.formatters"
|
||||
local linters = require "lsp.null-ls.linters"
|
||||
|
||||
local formatters = require "lsp.null-ls.formatters"
|
||||
local linters = require "lsp.null-ls.linters"
|
||||
|
||||
vim.list_extend(names, formatters.list_supported_names(filetype))
|
||||
vim.list_extend(names, linters.list_supported_names(filetype))
|
||||
|
||||
return names
|
||||
end
|
||||
|
||||
function M.list_unsupported_provider_names(filetype)
|
||||
local names = {}
|
||||
|
||||
local formatters = require "lsp.null-ls.formatters"
|
||||
local linters = require "lsp.null-ls.linters"
|
||||
|
||||
vim.list_extend(names, formatters.list_unsupported_names(filetype))
|
||||
vim.list_extend(names, linters.list_unsupported_names(filetype))
|
||||
|
||||
return names
|
||||
end
|
||||
|
||||
-- TODO: for linters and formatters with spaces and '-' replace with '_'
|
||||
function M.setup(filetype, options)
|
||||
options = options or {}
|
||||
|
||||
local ok, _ = pcall(require, "null-ls")
|
||||
if not ok then
|
||||
require("core.log"):error "Missing null-ls dependency"
|
||||
function M:setup()
|
||||
local status_ok, null_ls = pcall(require, "null-ls")
|
||||
if not status_ok then
|
||||
Log:error "Missing null-ls dependency"
|
||||
return
|
||||
end
|
||||
|
||||
local formatters = require "lsp.null-ls.formatters"
|
||||
local linters = require "lsp.null-ls.linters"
|
||||
|
||||
formatters.setup(filetype, options)
|
||||
linters.setup(filetype, options)
|
||||
null_ls.config()
|
||||
require("lspconfig")["null-ls"].setup {}
|
||||
for _, filetype in pairs(lvim.lang) do
|
||||
if filetype.formatters then
|
||||
formatters.setup(filetype.formatters, filetype)
|
||||
end
|
||||
if filetype.linters then
|
||||
linters.setup(filetype.linters, filetype)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue