move to backup
This commit is contained in:
parent
294dc66380
commit
a0e3d792a9
182 changed files with 156 additions and 103 deletions
25
bak/modules/nvim/config/lsp/astro.lua
Normal file
25
bak/modules/nvim/config/lsp/astro.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local function get_typescript_server_path(root_dir)
|
||||
local project_roots = vim.fs.find("node_modules", { path = root_dir, upward = true, limit = math.huge })
|
||||
for _, project_root in ipairs(project_roots) do
|
||||
local typescript_path = project_root .. "/typescript"
|
||||
local stat = vim.loop.fs_stat(typescript_path)
|
||||
if stat and stat.type == "directory" then
|
||||
return typescript_path .. "/lib"
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { "astro-ls", "--stdio" },
|
||||
filetypes = { "astro" },
|
||||
root_markers = { "package.json", "tsconfig.json", "jsconfig.json", ".git" },
|
||||
init_options = {
|
||||
typescript = {},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
|
||||
config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir)
|
||||
end
|
||||
end,
|
||||
}
|
||||
34
bak/modules/nvim/config/lsp/biome.lua
Normal file
34
bak/modules/nvim/config/lsp/biome.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = function(dispatchers, config)
|
||||
local cmd = 'biome'
|
||||
local local_cmd = (config or {}).root_dir and config.root_dir .. '/node_modules/.bin/biome'
|
||||
if local_cmd and vim.fn.executable(local_cmd) == 1 then
|
||||
cmd = local_cmd
|
||||
end
|
||||
return vim.lsp.rpc.start({ cmd, 'lsp-proxy' }, dispatchers)
|
||||
end,
|
||||
filetypes = {
|
||||
'astro',
|
||||
'css',
|
||||
'graphql',
|
||||
'html',
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'json',
|
||||
'jsonc',
|
||||
'svelte',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'vue',
|
||||
},
|
||||
workspace_required = true,
|
||||
root_markers = {
|
||||
'package-lock.json',
|
||||
'yarn.lock',
|
||||
'pnpm-lock.yaml',
|
||||
'bun.lockb',
|
||||
'bun.lock',
|
||||
'deno.lock',
|
||||
},
|
||||
}
|
||||
152
bak/modules/nvim/config/lsp/eslint.lua
Normal file
152
bak/modules/nvim/config/lsp/eslint.lua
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
local utils = require("dnsc.utils")
|
||||
local lsp = vim.lsp
|
||||
|
||||
local eslint_config_files = {
|
||||
".eslintrc",
|
||||
".eslintrc.js",
|
||||
".eslintrc.cjs",
|
||||
".eslintrc.yaml",
|
||||
".eslintrc.yml",
|
||||
".eslintrc.json",
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
"eslint.config.cjs",
|
||||
"eslint.config.ts",
|
||||
"eslint.config.mts",
|
||||
"eslint.config.cts",
|
||||
}
|
||||
|
||||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { "vscode-eslint-language-server", "--stdio" },
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"vue",
|
||||
"svelte",
|
||||
"astro",
|
||||
"htmlangular",
|
||||
},
|
||||
workspace_required = true,
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_create_user_command(0, "LspEslintFixAll", function()
|
||||
client:request_sync("workspace/executeCommand", {
|
||||
command = "eslint.applyAllFixes",
|
||||
arguments = {
|
||||
{
|
||||
uri = vim.uri_from_bufnr(bufnr),
|
||||
version = lsp.util.buf_versions[bufnr],
|
||||
},
|
||||
},
|
||||
}, nil, bufnr)
|
||||
end, {})
|
||||
end,
|
||||
root_markers = eslint_config_files,
|
||||
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
|
||||
settings = {
|
||||
validate = "on",
|
||||
packageManager = nil,
|
||||
useESLintClass = false,
|
||||
experimental = {
|
||||
useFlatConfig = false,
|
||||
},
|
||||
codeActionOnSave = {
|
||||
enable = false,
|
||||
mode = "all",
|
||||
},
|
||||
format = true,
|
||||
quiet = false,
|
||||
onIgnoredFiles = "off",
|
||||
rulesCustomizations = {},
|
||||
run = "onType",
|
||||
problems = {
|
||||
shortenToSingleLine = false,
|
||||
},
|
||||
-- nodePath configures the directory in which the eslint server should start its node_modules resolution.
|
||||
-- This path is relative to the workspace folder (root dir) of the server instance.
|
||||
nodePath = "",
|
||||
-- use the workspace folder location or the file location (if no workspace folder is open) as the working directory
|
||||
workingDirectory = { mode = "auto" },
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = "separateLine",
|
||||
},
|
||||
showDocumentation = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
-- The "workspaceFolder" is a VSCode concept. It limits how far the
|
||||
-- server will traverse the file system when locating the ESLint config
|
||||
-- file (e.g., .eslintrc).
|
||||
local root_dir = config.root_dir
|
||||
|
||||
if root_dir then
|
||||
config.settings = config.settings or {}
|
||||
config.settings.workspaceFolder = {
|
||||
uri = root_dir,
|
||||
name = vim.fn.fnamemodify(root_dir, ":t"),
|
||||
}
|
||||
|
||||
-- Support flat config files
|
||||
-- They contain 'config' in the file name
|
||||
local flat_config_files = vim.tbl_filter(function(file)
|
||||
return file:match("config")
|
||||
end, eslint_config_files)
|
||||
|
||||
for _, file in ipairs(flat_config_files) do
|
||||
local found_files = vim.fn.globpath(root_dir, file, true, true)
|
||||
|
||||
-- Filter out files inside node_modules
|
||||
local filtered_files = {}
|
||||
for _, found_file in ipairs(found_files) do
|
||||
if string.find(found_file, "[/\\]node_modules[/\\]") == nil then
|
||||
table.insert(filtered_files, found_file)
|
||||
end
|
||||
end
|
||||
|
||||
if #filtered_files > 0 then
|
||||
config.settings.experimental = config.settings.experimental or {}
|
||||
config.settings.experimental.useFlatConfig = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Support Yarn2 (PnP) projects
|
||||
local pnp_cjs = root_dir .. "/.pnp.cjs"
|
||||
local pnp_js = root_dir .. "/.pnp.js"
|
||||
if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then
|
||||
local cmd = config.cmd
|
||||
config.cmd = vim.list_extend({ "yarn", "exec" }, cmd)
|
||||
end
|
||||
end
|
||||
end,
|
||||
handlers = {
|
||||
["eslint/openDoc"] = function(_, result)
|
||||
if result then
|
||||
vim.ui.open(result.url)
|
||||
end
|
||||
return {}
|
||||
end,
|
||||
["eslint/confirmESLintExecution"] = function(_, result)
|
||||
if not result then
|
||||
return
|
||||
end
|
||||
return 4 -- approved
|
||||
end,
|
||||
["eslint/probeFailed"] = function()
|
||||
vim.notify("[lspconfig] ESLint probe failed.", vim.log.levels.WARN)
|
||||
return {}
|
||||
end,
|
||||
["eslint/noLibrary"] = function()
|
||||
vim.notify("[lspconfig] Unable to find ESLint library.", vim.log.levels.WARN)
|
||||
return {}
|
||||
end,
|
||||
},
|
||||
}
|
||||
99
bak/modules/nvim/config/lsp/gopls.lua
Normal file
99
bak/modules/nvim/config/lsp/gopls.lua
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
---@brief
|
||||
---
|
||||
--- https://github.com/golang/tools/tree/master/gopls
|
||||
---
|
||||
--- Google's lsp server for golang.
|
||||
|
||||
--- @class go_dir_custom_args
|
||||
---
|
||||
--- @field envvar_id string
|
||||
---
|
||||
--- @field custom_subdir string?
|
||||
|
||||
local mod_cache = nil
|
||||
local std_lib = nil
|
||||
|
||||
---@param custom_args go_dir_custom_args
|
||||
---@param on_complete fun(dir: string | nil)
|
||||
local function identify_go_dir(custom_args, on_complete)
|
||||
local cmd = { "go", "env", custom_args.envvar_id }
|
||||
vim.system(cmd, { text = true }, function(output)
|
||||
local res = vim.trim(output.stdout or "")
|
||||
if output.code == 0 and res ~= "" then
|
||||
if custom_args.custom_subdir and custom_args.custom_subdir ~= "" then
|
||||
res = res .. custom_args.custom_subdir
|
||||
end
|
||||
on_complete(res)
|
||||
else
|
||||
vim.schedule(function()
|
||||
vim.notify(
|
||||
("[gopls] identify " .. custom_args.envvar_id .. " dir cmd failed with code %d: %s\n%s"):format(
|
||||
output.code,
|
||||
vim.inspect(cmd),
|
||||
output.stderr
|
||||
)
|
||||
)
|
||||
end)
|
||||
on_complete(nil)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
---@return string?
|
||||
local function get_std_lib_dir()
|
||||
if std_lib and std_lib ~= "" then
|
||||
return std_lib
|
||||
end
|
||||
|
||||
identify_go_dir({ envvar_id = "GOROOT", custom_subdir = "/src" }, function(dir)
|
||||
if dir then
|
||||
std_lib = dir
|
||||
end
|
||||
end)
|
||||
return std_lib
|
||||
end
|
||||
|
||||
---@return string?
|
||||
local function get_mod_cache_dir()
|
||||
if mod_cache and mod_cache ~= "" then
|
||||
return mod_cache
|
||||
end
|
||||
|
||||
identify_go_dir({ envvar_id = "GOMODCACHE" }, function(dir)
|
||||
if dir then
|
||||
mod_cache = dir
|
||||
end
|
||||
end)
|
||||
return mod_cache
|
||||
end
|
||||
|
||||
---@param fname string
|
||||
---@return string?
|
||||
local function get_root_dir(fname)
|
||||
if mod_cache and fname:sub(1, #mod_cache) == mod_cache then
|
||||
local clients = vim.lsp.get_clients({ name = "gopls" })
|
||||
if #clients > 0 then
|
||||
return clients[#clients].config.root_dir
|
||||
end
|
||||
end
|
||||
if std_lib and fname:sub(1, #std_lib) == std_lib then
|
||||
local clients = vim.lsp.get_clients({ name = "gopls" })
|
||||
if #clients > 0 then
|
||||
return clients[#clients].config.root_dir
|
||||
end
|
||||
end
|
||||
return vim.fs.root(fname, "go.work") or vim.fs.root(fname, "go.mod") or vim.fs.root(fname, ".git")
|
||||
end
|
||||
|
||||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
get_mod_cache_dir()
|
||||
get_std_lib_dir()
|
||||
-- see: https://github.com/neovim/nvim-lspconfig/issues/804
|
||||
on_dir(get_root_dir(fname))
|
||||
end,
|
||||
}
|
||||
15
bak/modules/nvim/config/lsp/jsonls.lua
Normal file
15
bak/modules/nvim/config/lsp/jsonls.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
return {
|
||||
cmd = { "vscode-json-language-server", "--stdio" },
|
||||
filetypes = { "json", "jsonc" },
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
},
|
||||
root_markers = { ".git" },
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
validate = { enable = true },
|
||||
},
|
||||
},
|
||||
}
|
||||
46
bak/modules/nvim/config/lsp/lua_ls.lua
Normal file
46
bak/modules/nvim/config/lsp/lua_ls.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
return {
|
||||
cmd = { "lua-language-server" },
|
||||
filetypes = { "lua" },
|
||||
root_markers = {
|
||||
".luarc.json",
|
||||
".luarc.jsonc",
|
||||
".luacheckrc",
|
||||
".stylua.toml",
|
||||
"stylua.toml",
|
||||
"selene.toml",
|
||||
"selene.yml",
|
||||
".git",
|
||||
},
|
||||
single_file_support = true,
|
||||
log_level = vim.lsp.protocol.MessageType.Warning,
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if
|
||||
path ~= vim.fn.stdpath("config")
|
||||
and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc"))
|
||||
then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
5
bak/modules/nvim/config/lsp/nil_ls.lua
Normal file
5
bak/modules/nvim/config/lsp/nil_ls.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
cmd = { "nil" },
|
||||
filetypes = { "nix" },
|
||||
root_markers = { "flake.nix", ".git" },
|
||||
}
|
||||
153
bak/modules/nvim/config/lsp/tailwindcss.lua
Normal file
153
bak/modules/nvim/config/lsp/tailwindcss.lua
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
function root_markers_with_field(root_files, new_names, field, fname)
|
||||
local path = vim.fn.fnamemodify(fname, ":h")
|
||||
local found = vim.fs.find(new_names, { path = path, upward = true })
|
||||
|
||||
for _, f in ipairs(found or {}) do
|
||||
-- Match the given `field`.
|
||||
for line in io.lines(f) do
|
||||
if line:find(field) then
|
||||
root_files[#root_files + 1] = vim.fs.basename(f)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return root_files
|
||||
end
|
||||
|
||||
function insert_package_json(root_files, field, fname)
|
||||
return root_markers_with_field(root_files, { "package.json", "package.json5" }, field, fname)
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { "tailwindcss-language-server", "--stdio" },
|
||||
-- filetypes copied and adjusted from tailwindcss-intellisense
|
||||
filetypes = {
|
||||
-- html
|
||||
"aspnetcorerazor",
|
||||
"astro",
|
||||
"astro-markdown",
|
||||
"blade",
|
||||
"clojure",
|
||||
"django-html",
|
||||
"htmldjango",
|
||||
"edge",
|
||||
"eelixir", -- vim ft
|
||||
"elixir",
|
||||
"ejs",
|
||||
"erb",
|
||||
"eruby", -- vim ft
|
||||
"gohtml",
|
||||
"gohtmltmpl",
|
||||
"haml",
|
||||
"handlebars",
|
||||
"hbs",
|
||||
"html",
|
||||
"htmlangular",
|
||||
"html-eex",
|
||||
"heex",
|
||||
"jade",
|
||||
"leaf",
|
||||
"liquid",
|
||||
"markdown",
|
||||
"mdx",
|
||||
"mustache",
|
||||
"njk",
|
||||
"nunjucks",
|
||||
"php",
|
||||
"razor",
|
||||
"slim",
|
||||
"twig",
|
||||
-- css
|
||||
"css",
|
||||
"less",
|
||||
"postcss",
|
||||
"sass",
|
||||
"scss",
|
||||
"stylus",
|
||||
"sugarss",
|
||||
-- js
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"reason",
|
||||
"rescript",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
-- mixed
|
||||
"vue",
|
||||
"svelte",
|
||||
"templ",
|
||||
},
|
||||
settings = {
|
||||
tailwindCSS = {
|
||||
validate = true,
|
||||
lint = {
|
||||
cssConflict = "warning",
|
||||
invalidApply = "error",
|
||||
invalidScreen = "error",
|
||||
invalidVariant = "error",
|
||||
invalidConfigPath = "error",
|
||||
invalidTailwindDirective = "error",
|
||||
recommendedVariantOrder = "warning",
|
||||
},
|
||||
classAttributes = {
|
||||
"class",
|
||||
"className",
|
||||
"class:list",
|
||||
"classList",
|
||||
"ngClass",
|
||||
},
|
||||
includeLanguages = {
|
||||
eelixir = "html-eex",
|
||||
elixir = "phoenix-heex",
|
||||
eruby = "erb",
|
||||
heex = "phoenix-heex",
|
||||
htmlangular = "html",
|
||||
templ = "html",
|
||||
},
|
||||
},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
if not config.settings then
|
||||
config.settings = {}
|
||||
end
|
||||
if not config.settings.editor then
|
||||
config.settings.editor = {}
|
||||
end
|
||||
if not config.settings.editor.tabSize then
|
||||
config.settings.editor.tabSize = vim.lsp.util.get_effective_tabstop()
|
||||
end
|
||||
end,
|
||||
workspace_required = true,
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local root_files = {
|
||||
-- Generic
|
||||
"tailwind.config.js",
|
||||
"tailwind.config.cjs",
|
||||
"tailwind.config.mjs",
|
||||
"tailwind.config.ts",
|
||||
"postcss.config.js",
|
||||
"postcss.config.cjs",
|
||||
"postcss.config.mjs",
|
||||
"postcss.config.ts",
|
||||
-- Phoenix
|
||||
"assets/tailwind.config.js",
|
||||
"assets/tailwind.config.cjs",
|
||||
"assets/tailwind.config.mjs",
|
||||
"assets/tailwind.config.ts",
|
||||
-- Django
|
||||
"theme/static_src/tailwind.config.js",
|
||||
"theme/static_src/tailwind.config.cjs",
|
||||
"theme/static_src/tailwind.config.mjs",
|
||||
"theme/static_src/tailwind.config.ts",
|
||||
"theme/static_src/postcss.config.js",
|
||||
-- Rails
|
||||
"app/assets/stylesheets/application.tailwind.css",
|
||||
"app/assets/tailwind/application.css",
|
||||
}
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
root_files = insert_package_json(root_files, "tailwindcss", fname)
|
||||
root_files = root_markers_with_field(root_files, { "mix.lock" }, "tailwind", fname)
|
||||
on_dir(vim.fs.dirname(vim.fs.find(root_files, { path = fname, upward = true })[1]))
|
||||
end,
|
||||
}
|
||||
22
bak/modules/nvim/config/lsp/ts_ls.lua
Normal file
22
bak/modules/nvim/config/lsp/ts_ls.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
return {
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
},
|
||||
root_markers = { "tsconfig.json", "package.json", ".git" },
|
||||
init_options = {
|
||||
hostInfo = "neovim",
|
||||
preferences = {
|
||||
includeCompletionsForModuleExports = true,
|
||||
includeCompletionsForImportStatements = true,
|
||||
importModuleSpecifierPreference = "relative",
|
||||
importModuleSpecifierEnding = "minimal",
|
||||
},
|
||||
},
|
||||
single_file_support = true,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue