|
|
|
@ -1,16 +1,19 @@
|
|
|
|
|
local lsp = require("lspconfig")
|
|
|
|
|
local aerial = require("aerial")
|
|
|
|
|
|
|
|
|
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|
|
|
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
|
|
|
signs = true,
|
|
|
|
|
virtual_text = true,
|
|
|
|
|
underline = true
|
|
|
|
|
})
|
|
|
|
|
vim.lsp.handlers["textDocument/publishDiagnostics"] =
|
|
|
|
|
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
|
|
|
signs = true,
|
|
|
|
|
virtual_text = true,
|
|
|
|
|
underline = true
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
local noremap = function(lhs, rhs, mode)
|
|
|
|
|
mode = mode or 'n'
|
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
|
local opts = {
|
|
|
|
|
noremap = true,
|
|
|
|
|
silent = true
|
|
|
|
|
}
|
|
|
|
|
vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, opts)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -29,7 +32,7 @@ local set_lsp_config = function(client, bufnr)
|
|
|
|
|
['gi'] = '<cmd>lua vim.lsp.buf.implementation()<CR>',
|
|
|
|
|
['<silent>gh'] = '<cmd>Lspsaga lsp_finder',
|
|
|
|
|
['gh'] = '<cmd>Lspsaga lsp_finder<CR>',
|
|
|
|
|
['<leader>ca'] = '<cmd>Lspsaga code_action<CR>',
|
|
|
|
|
['<leader>ca'] = '<cmd>Lspsaga code_action<CR>',
|
|
|
|
|
['K'] = '<cmd>Lspsaga hover_doc<CR>',
|
|
|
|
|
['gs'] = '<cmd>Lspsaga signature_help<CR>',
|
|
|
|
|
['gr'] = '<cmd>Lspsaga rename<CR>',
|
|
|
|
@ -39,7 +42,7 @@ local set_lsp_config = function(client, bufnr)
|
|
|
|
|
[']e'] = '<cmd>Lspsaga diagnostic_jump_prev<CR>',
|
|
|
|
|
['<leader>co'] = '<cmd>AerialToggle!<CR>',
|
|
|
|
|
['[['] = '<cmd>AerialPrevUp<CR>',
|
|
|
|
|
[']]'] = '<cmd>AerialNext<CR>',
|
|
|
|
|
[']]'] = '<cmd>AerialNext<CR>'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -50,12 +53,26 @@ local set_lsp_config = function(client, bufnr)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Lua
|
|
|
|
|
require('nlua.lsp.nvim').setup(lsp, {
|
|
|
|
|
on_attach = set_lsp_config,
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- C/C++
|
|
|
|
|
lsp.clangd.setup {
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- Golang
|
|
|
|
|
lsp.gopls.setup {
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- PHP
|
|
|
|
|
lsp.phpactor.setup {
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- Typescript
|
|
|
|
|
lsp.tsserver.setup {
|
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
@ -65,48 +82,9 @@ lsp.tsserver.setup {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- Python
|
|
|
|
|
|
|
|
|
|
lsp.pyright.setup{
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- lsp.pyls.setup{
|
|
|
|
|
-- on_attach = set_lsp_config,
|
|
|
|
|
-- settings = {
|
|
|
|
|
-- pyls = {
|
|
|
|
|
-- plugins = {
|
|
|
|
|
-- jedi_completion = {enabled = false},
|
|
|
|
|
-- jedi_definition = {enabled = false},
|
|
|
|
|
-- yapf = {enabled = false},
|
|
|
|
|
-- rope_completion = {enabled = false},
|
|
|
|
|
-- pylint = {enabled = false},
|
|
|
|
|
-- pyflakes = {enabled = false},
|
|
|
|
|
-- pydocstyle = {enabled = false},
|
|
|
|
|
-- preload = {enabled = false},
|
|
|
|
|
-- mccabe = {enabled = false},
|
|
|
|
|
-- jedi_symbols = {enabled = false},
|
|
|
|
|
-- jedi_references = {enabled = false},
|
|
|
|
|
-- }}}}
|
|
|
|
|
|
|
|
|
|
-- EFM
|
|
|
|
|
|
|
|
|
|
-- local function eslint_config_exists()
|
|
|
|
|
-- local eslintrc = vim.fn.glob(".eslintrc*", 0, 1)
|
|
|
|
|
--
|
|
|
|
|
-- if not vim.tbl_isempty(eslintrc) then
|
|
|
|
|
-- return true
|
|
|
|
|
-- end
|
|
|
|
|
--
|
|
|
|
|
-- if vim.fn.filereadable("package.json") then
|
|
|
|
|
-- if vim.fn.json_decode(vim.fn.readfile("package.json"))["eslintConfig"] then
|
|
|
|
|
-- return true
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
--
|
|
|
|
|
-- return false
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
lsp.pyright.setup {
|
|
|
|
|
on_attach = set_lsp_config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local eslint = {
|
|
|
|
|
lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
|
|
|
|
@ -125,31 +103,37 @@ local flake8 = {
|
|
|
|
|
|
|
|
|
|
local isort = {
|
|
|
|
|
formatCommand = "isort --profile black -",
|
|
|
|
|
formatStdin = true,
|
|
|
|
|
formatStdin = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local phpstan = {
|
|
|
|
|
lintCommand = "./vendor/bin/phpstan analyze --error-format raw --no-progress"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lsp.efm.setup {
|
|
|
|
|
init_options = {
|
|
|
|
|
hover = true,
|
|
|
|
|
documentSymbol = true,
|
|
|
|
|
codeAction = true,
|
|
|
|
|
completion = true,
|
|
|
|
|
documentFormatting = true
|
|
|
|
|
},
|
|
|
|
|
filetypes = {"javascript", "typescript", "javascriptreact", "typescriptreact", "python" },
|
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
|
set_lsp_config(client, bufnr)
|
|
|
|
|
end,
|
|
|
|
|
root_dir = function()
|
|
|
|
|
-- if not eslint_config_exists() then
|
|
|
|
|
-- return nil
|
|
|
|
|
-- end
|
|
|
|
|
return vim.fn.getcwd()
|
|
|
|
|
end,
|
|
|
|
|
filetypes = {
|
|
|
|
|
"javascript", "typescript", "javascriptreact", "typescriptreact",
|
|
|
|
|
"python", "php", "blade"
|
|
|
|
|
},
|
|
|
|
|
on_attach = function(client, bufnr) set_lsp_config(client, bufnr) end,
|
|
|
|
|
root_dir = function() return vim.fn.getcwd() end,
|
|
|
|
|
settings = {
|
|
|
|
|
rootMarkers = {".eslintrc", ".eslintrc.js", ".git/", "pyproject.toml" },
|
|
|
|
|
rootMarkers = {".eslintrc", ".eslintrc.js", ".git/", "pyproject.toml"},
|
|
|
|
|
languages = {
|
|
|
|
|
javascript = {eslint},
|
|
|
|
|
javascriptreact = {eslint},
|
|
|
|
|
typescript = {eslint},
|
|
|
|
|
typescriptreact = {eslint},
|
|
|
|
|
python = {flake8, isort}
|
|
|
|
|
python = {flake8, isort},
|
|
|
|
|
php = {phpstan},
|
|
|
|
|
blade = {phpstan}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|