feat: eww hypr alacritty and more
This commit is contained in:
parent
1f3c2b9947
commit
7fb4f9ee73
132 changed files with 23 additions and 4881 deletions
|
|
@ -1,165 +0,0 @@
|
|||
local util = require 'lspconfig.util'
|
||||
local lsp = vim.lsp
|
||||
|
||||
local function fix_all(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local eslint_lsp_client = util.get_active_client_by_name(opts.bufnr, 'eslint')
|
||||
if eslint_lsp_client == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local request
|
||||
if opts.sync then
|
||||
request = function(bufnr, method, params)
|
||||
eslint_lsp_client.request_sync(method, params, nil, bufnr)
|
||||
end
|
||||
else
|
||||
request = function(bufnr, method, params)
|
||||
eslint_lsp_client.request(method, params, nil, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
local bufnr = util.validate_bufnr(opts.bufnr or 0)
|
||||
request(0, 'workspace/executeCommand', {
|
||||
command = 'eslint.applyAllFixes',
|
||||
arguments = {
|
||||
{
|
||||
uri = vim.uri_from_bufnr(bufnr),
|
||||
version = lsp.util.buf_versions[bufnr],
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
local bin_name = 'vscode-eslint-language-server'
|
||||
local cmd = { bin_name, '--stdio' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
filetypes = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
'vue',
|
||||
},
|
||||
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
|
||||
root_dir = util.root_pattern(
|
||||
'.eslintrc',
|
||||
'.eslintrc.js',
|
||||
'.eslintrc.cjs',
|
||||
'.eslintrc.yaml',
|
||||
'.eslintrc.yml',
|
||||
'.eslintrc.json',
|
||||
'package.json'
|
||||
),
|
||||
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
|
||||
settings = {
|
||||
validate = 'on',
|
||||
packageManager = 'npm',
|
||||
useESLintClass = false,
|
||||
codeActionOnSave = {
|
||||
enable = false,
|
||||
mode = 'all',
|
||||
},
|
||||
format = true,
|
||||
quiet = false,
|
||||
onIgnoredFiles = 'off',
|
||||
rulesCustomizations = {},
|
||||
run = 'onType',
|
||||
-- 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 = 'location' },
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = 'separateLine',
|
||||
},
|
||||
showDocumentation = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
on_new_config = function(config, new_root_dir)
|
||||
-- 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).
|
||||
config.settings.workspaceFolder = {
|
||||
uri = new_root_dir,
|
||||
name = vim.fn.fnamemodify(new_root_dir, ':t'),
|
||||
}
|
||||
|
||||
-- Support Yarn2 (PnP) projects
|
||||
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
|
||||
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
|
||||
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
|
||||
config.cmd = vim.list_extend({ 'yarn', 'exec' }, cmd)
|
||||
end
|
||||
end,
|
||||
handlers = {
|
||||
['eslint/openDoc'] = function(_, result)
|
||||
if not result then
|
||||
return
|
||||
end
|
||||
local sysname = vim.loop.os_uname().sysname
|
||||
if sysname:match 'Windows' then
|
||||
os.execute(string.format('start %q', result.url))
|
||||
elseif sysname:match 'Linux' then
|
||||
os.execute(string.format('xdg-open %q', result.url))
|
||||
else
|
||||
os.execute(string.format('open %q', 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,
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
EslintFixAll = {
|
||||
function()
|
||||
fix_all { sync = true, bufnr = 0 }
|
||||
end,
|
||||
description = 'Fix all eslint problems for this buffer',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
`vscode-eslint-language-server` is a linting engine for JavaScript / Typescript.
|
||||
It can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g vscode-langservers-extracted
|
||||
```
|
||||
`vscode-eslint-language-server` provides an `EslintFixAll` command that can be used to format a document on save:
|
||||
```vim
|
||||
autocmd BufWritePre *.tsx,*.ts,*.jsx,*.js EslintFixAll
|
||||
```
|
||||
See [vscode-eslint](https://github.com/microsoft/vscode-eslint/blob/55871979d7af184bf09af491b6ea35ebd56822cf/server/src/eslintServer.ts#L216-L229) for configuration options.
|
||||
Messages handled in lspconfig: `eslint/openDoc`, `eslint/confirmESLintExecution`, `eslint/probeFailed`, `eslint/noLibrary`
|
||||
Additional messages you can handle: `eslint/noConfig`
|
||||
]],
|
||||
},
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
-- TODO: backfill this to template
|
||||
M.setup = function()
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = "" },
|
||||
{ name = "DiagnosticSignWarn", text = "" },
|
||||
{ name = "DiagnosticSignHint", text = "" },
|
||||
{ name = "DiagnosticSignInfo", text = "" },
|
||||
}
|
||||
|
||||
for _, sign in ipairs(signs) do
|
||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||
end
|
||||
|
||||
local config = {
|
||||
-- disable virtual text
|
||||
virtual_text = false,
|
||||
-- show signs
|
||||
signs = {
|
||||
active = signs,
|
||||
},
|
||||
update_in_insert = true,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
}
|
||||
|
||||
vim.diagnostic.config(config)
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = "rounded",
|
||||
})
|
||||
end
|
||||
|
||||
local function lsp_highlight_document(client)
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
local status_ok, illuminate = pcall(require, "illuminate")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
illuminate.on_attach(client)
|
||||
-- end
|
||||
end
|
||||
|
||||
local function lsp_keymaps(bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
bufnr,
|
||||
"n",
|
||||
"gl",
|
||||
'<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>',
|
||||
opts
|
||||
)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
||||
end
|
||||
|
||||
M.on_attach = function(client, bufnr)
|
||||
-- vim.notify(client.name .. " starting...")
|
||||
-- TODO: refactor this into a method that checks if string in list
|
||||
if client.name == "tsserver" then
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
end
|
||||
lsp_keymaps(bufnr)
|
||||
lsp_highlight_document(client)
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities)
|
||||
|
||||
return M
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local bin_name = 'vscode-html-language-server'
|
||||
local cmd = { bin_name, '--stdio' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
filetypes = { 'html' },
|
||||
root_dir = util.root_pattern('package.json', '.git'),
|
||||
single_file_support = true,
|
||||
settings = {},
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
embeddedLanguages = { css = true, javascript = true },
|
||||
configurationSection = { 'html', 'css', 'javascript' },
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
`vscode-html-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g vscode-langservers-extracted
|
||||
```
|
||||
Neovim does not currently include built-in snippets. `vscode-html-language-server` only provides completions when snippet support is enabled.
|
||||
To enable completion, install a snippet plugin and add the following override to your language client capabilities during setup.
|
||||
The code-formatting feature of the lsp can be controlled with the `provideFormatter` option.
|
||||
```lua
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
require'lspconfig'.html.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
return {
|
||||
settings = {
|
||||
|
||||
java = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local bin_name = 'pyright-langserver'
|
||||
local cmd = { bin_name, '--stdio' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
|
||||
end
|
||||
|
||||
local root_files = {
|
||||
'pyproject.toml',
|
||||
'setup.py',
|
||||
'setup.cfg',
|
||||
'requirements.txt',
|
||||
'Pipfile',
|
||||
'pyrightconfig.json',
|
||||
}
|
||||
|
||||
local function organize_imports()
|
||||
local params = {
|
||||
command = 'pyright.organizeimports',
|
||||
arguments = { vim.uri_from_bufnr(0) },
|
||||
}
|
||||
vim.lsp.buf.execute_command(params)
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
filetypes = { 'python' },
|
||||
root_dir = util.root_pattern(unpack(root_files)),
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = 'workspace',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
PyrightOrganizeImports = {
|
||||
organize_imports,
|
||||
description = 'Organize Imports',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/microsoft/pyright
|
||||
`pyright`, a static type checker and language server for python
|
||||
]],
|
||||
},
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
return {
|
||||
settings = {
|
||||
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
return {
|
||||
settings = {
|
||||
|
||||
latex = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue