mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-04 10:05:37 +02:00
feat: add css (and pre-processors) support (#937)
This commit is contained in:
parent
946b251233
commit
acb685c093
2 changed files with 37 additions and 0 deletions
|
@ -1,3 +1,36 @@
|
|||
vim.cmd "let proj = FindRootDirectory()"
|
||||
local root_dir = vim.api.nvim_get_var "proj"
|
||||
|
||||
-- use the global prettier if you didn't find the local one
|
||||
local prettier_instance = root_dir .. "/node_modules/.bin/prettier"
|
||||
if vim.fn.executable(prettier_instance) ~= 1 then
|
||||
prettier_instance = O.lang.tsserver.formatter.exe
|
||||
end
|
||||
|
||||
local ft = vim.bo.filetype
|
||||
O.formatters.filetype[ft]= {
|
||||
function()
|
||||
local args = { "--stdin-filepath", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) }
|
||||
-- TODO: O.lang.[ft].formatter.args
|
||||
local extend_args = O.lang.css.formatter.args
|
||||
|
||||
for i = 1, #extend_args do
|
||||
table.insert(args, extend_args[i])
|
||||
end
|
||||
|
||||
return {
|
||||
exe = prettier_instance,
|
||||
args = args,
|
||||
stdin = true
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
require("formatter.config").set_defaults {
|
||||
logging = false,
|
||||
filetype = O.formatters.filetype,
|
||||
}
|
||||
|
||||
if not require("lv-utils").check_lsp_client_active "cssls" then
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
|
|
@ -107,6 +107,10 @@ O = {
|
|||
},
|
||||
css = {
|
||||
virtual_text = true,
|
||||
formatter = {
|
||||
exe = "prettier",
|
||||
args = {},
|
||||
},
|
||||
},
|
||||
dart = {
|
||||
sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue