feat: add nvim
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
-- npm i -g bash-language-server
|
||||
require'lspconfig'.bashls.setup {
|
||||
cmd = {DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
filetypes = { "sh", "zsh" }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
-- npm install -g vscode-css-languageserver-bin
|
||||
require'lspconfig'.cssls.setup {
|
||||
cmd = {
|
||||
"node", DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js",
|
||||
"--stdio"
|
||||
},
|
||||
on_attach = require'lsp'.common_on_attach
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
-- npm install -g dockerfile-language-server-nodejs
|
||||
require'lspconfig'.dockerls.setup {
|
||||
cmd = {DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
root_dir = vim.loop.cwd
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
local nvim_lsp = require'lspconfig'
|
||||
local configs = require'lspconfig/configs'
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
configs.emmet_ls = {
|
||||
default_config = {
|
||||
cmd = {'emmet-ls', '--stdio'};
|
||||
filetypes = {'html', 'css'};
|
||||
root_dir = function()
|
||||
return vim.loop.cwd()
|
||||
end;
|
||||
settings = {};
|
||||
};
|
||||
}
|
||||
|
||||
nvim_lsp.emmet_ls.setup{
|
||||
-- on_attach = on_attach;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
-- LSP
|
||||
require'lspconfig'.gopls.setup{
|
||||
cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
|
||||
settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}},
|
||||
root_dir = require'lspconfig'.util.root_pattern(".git","go.mod"),
|
||||
init_options = {usePlaceholders = true, completeUnimported = true},
|
||||
on_attach = require'lsp'.common_on_attach
|
||||
}
|
||||
|
||||
require'dap-install'.config("go_delve",{})
|
||||
|
||||
-- DAP
|
||||
local dap = require "dap"
|
||||
vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''})
|
||||
--vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''})
|
||||
|
||||
local M = {}
|
||||
|
||||
local ts_utils = require 'nvim-treesitter.ts_utils'
|
||||
|
||||
function M.get_node()
|
||||
local n = ts_utils.get_node_at_cursor()
|
||||
put(ts_utils.get_node_text(n))
|
||||
end
|
||||
|
||||
function M.get_node2()
|
||||
local current_node = ts_utils.get_node_at_cursor()
|
||||
if not current_node then
|
||||
return ""
|
||||
end
|
||||
|
||||
local expr = current_node
|
||||
|
||||
while expr do
|
||||
if expr:type() == 'function_definition' then
|
||||
put(expr:type())
|
||||
break
|
||||
end
|
||||
expr = expr:parent()
|
||||
end
|
||||
|
||||
if not expr then return "" end
|
||||
|
||||
put(ts_utils.get_node_text(expr))
|
||||
return (ts_utils.get_node_text(expr:child(1)))[1]
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
--[[
|
||||
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
|
||||
dap.configurations.go = {
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug",
|
||||
request = "launch",
|
||||
program = "${file}"
|
||||
},
|
||||
-- works with go.mod packages and sub packagesfunction M.get_current_function_name() local current_node = ts_utils.get_node_at_cursor() if not current_node then return "" end
|
||||
|
||||
local expr = current_node
|
||||
|
||||
while expr do
|
||||
if expr:type() == 'function_definition' then
|
||||
break
|
||||
end
|
||||
expr = expr:parent()
|
||||
end
|
||||
|
||||
if not expr then return "" end
|
||||
|
||||
return (ts_utils.get_node_text(expr:child(1)))[1]
|
||||
end
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug test (go.mod)",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "./${relativeFileDirname}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
--[[
|
||||
local dap = require('dap')
|
||||
|
||||
dap.adapters.go = function(callback, config)
|
||||
local stdout = vim.loop.new_pipe(false)
|
||||
local handle
|
||||
local pid_or_err
|
||||
local port = 38697
|
||||
local opts = {
|
||||
stdio = {nil, stdout},
|
||||
args = {"dap", "-l", "127.0.0.1:" .. port},
|
||||
detached = true
|
||||
}
|
||||
handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code)
|
||||
stdout:close()
|
||||
handle:close()
|
||||
if code ~= 0 then
|
||||
print('dlv exited with code', code)
|
||||
end
|
||||
end)
|
||||
assert(handle, 'Error running dlv: ' .. tostring(pid_or_err))
|
||||
stdout:read_start(function(err, chunk)
|
||||
assert(not err, err)
|
||||
if chunk then
|
||||
vim.schedule(function()
|
||||
require('dap.repl').append(chunk)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
-- Wait for delve to start
|
||||
vim.defer_fn(
|
||||
function()
|
||||
callback({type = "server", host = "127.0.0.1", port = port})
|
||||
end,
|
||||
100)
|
||||
end
|
||||
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
|
||||
dap.configurations.go = {
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug",
|
||||
request = "launch",
|
||||
program = "${file}"
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug test", -- configuration for debugging test files
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "${file}"
|
||||
},
|
||||
-- works with go.mod packages and sub packages
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug test (go.mod)",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "./${relativeFileDirname}"
|
||||
}
|
||||
}
|
||||
]]
|
||||
@@ -0,0 +1,9 @@
|
||||
-- npm install -g vscode-html-languageserver-bin
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require'lspconfig'.html.setup {
|
||||
cmd = {"node", DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", "--stdio"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
-- npm install -g typescript typescript-language-server
|
||||
-- require'snippets'.use_suggested_mappings()
|
||||
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
-- capabilities.textDocument.completion.completionItem.snippetSupport = true;
|
||||
-- local on_attach_common = function(client)
|
||||
-- print("LSP Initialized")
|
||||
-- require'completion'.on_attach(client)
|
||||
-- require'illuminate'.on_attach(client)
|
||||
-- end
|
||||
|
||||
require'lspconfig'.tsserver.setup {
|
||||
cmd = {DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", "--stdio"},
|
||||
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
|
||||
on_attach = require'lsp'.tsserver_on_attach,
|
||||
-- This makes sure tsserver is not used for formatting (I prefer prettier)
|
||||
-- on_attach = require'lsp'.common_on_attach,
|
||||
root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||
settings = {documentFormatting = false},
|
||||
handlers = {
|
||||
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = O.tsserver.diagnostics.virtual_text,
|
||||
signs = O.tsserver.diagnostics.signs,
|
||||
underline = O.tsserver.diagnostics.underline,
|
||||
update_in_insert = true
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
-- npm install -g vscode-json-languageserver
|
||||
require'lspconfig'.jsonls.setup {
|
||||
cmd = {
|
||||
"node", DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
|
||||
"--stdio"
|
||||
},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({}, {0, 0}, {vim.fn.line("$"), 0})
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
require'lspconfig'.texlab.setup{
|
||||
cmd = {DATA_PATH .. "/lspinstall/latex/texlab"},
|
||||
on_attach = require'lsp'.common_on_attach
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
-- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
|
||||
local brew_path = "/usr/local/Cellar/lua-language-server/2.5.5/libexec"
|
||||
local sumneko_root_path = brew_path
|
||||
local sumneko_binary = brew_path .. "/bin/lua-language-server"
|
||||
|
||||
require'lspconfig'.sumneko_lua.setup {
|
||||
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = vim.split(package.path, ';')
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = {'vim'}
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true},
|
||||
maxPreload = 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
-- npm i -g pyright
|
||||
require'lspconfig'.pyright.setup {
|
||||
cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
handlers = {
|
||||
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = O.python.diagnostics.virtual_text,
|
||||
signs = O.python.diagnostics.signs,
|
||||
underline = O.python.diagnostics.underline,
|
||||
update_in_insert = true
|
||||
})
|
||||
},
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = O.python.analysis.type_checking,
|
||||
autoSearchPaths = O.python.analysis.auto_search_paths,
|
||||
useLibraryCodeForTypes = O.python.analysis.use_library_code_types
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
require'lspconfig'.rust_analyzer.setup{
|
||||
cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
|
||||
on_attach = require'lsp'.common_on_attach
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- npm install -g yaml-language-server
|
||||
require'lspconfig'.yamlls.setup{
|
||||
cmd = {DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio"},
|
||||
on_attach = require'lsp'.common_on_attach,
|
||||
}
|
||||
Reference in New Issue
Block a user