feat: add css (and pre-processors) support (#937)

This commit is contained in:
not 2021-07-14 10:05:09 -05:00 committed by GitHub
parent 946b251233
commit acb685c093
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -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

View file

@ -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",