Base LSP
+ loads LSP server based on file type + imports native-lsp (our's) and lspconfig (foreign) + key mappings for lsp
This commit is contained in:
parent
14b563ff20
commit
052b4513c2
3 changed files with 142 additions and 22 deletions
3
init.lua
3
init.lua
|
@ -22,7 +22,8 @@ env = vim.env -- environment variables
|
|||
local modules = {
|
||||
'general',
|
||||
'keymap',
|
||||
'ui'
|
||||
'ui',
|
||||
'native-lsp'
|
||||
}
|
||||
|
||||
local async
|
||||
|
|
|
@ -275,27 +275,26 @@ end
|
|||
map('n', '<leader>p', ':lua pm_sync()<CR>', {noremap = true})
|
||||
|
||||
-- LSP
|
||||
function lsp_shortcuts()
|
||||
local lsp_commands = {
|
||||
new = {'d','r','f','t','x','a','c','C','h','s','m'},
|
||||
old = {
|
||||
'#textDocument_definition', -- d
|
||||
'#textDocument_rename', -- r
|
||||
'#textDocument_formatting', -- f
|
||||
'#textDocument_typeDefinition', -- t
|
||||
'#textDocument_references', -- x
|
||||
'_workspace_applyEdit', -- a
|
||||
'#textDocument_completion', -- c
|
||||
'#textDocument_codeAction', -- C
|
||||
'#textDocument_hover', -- h
|
||||
'_textDocument_documentSymbol', -- s
|
||||
'_contextMenu' -- m
|
||||
}
|
||||
local lsp_commands = {
|
||||
new = {'<', '>','a','d','D','f','h','n','r','s'},
|
||||
old = {
|
||||
'diagnostic.goto_prev', -- <
|
||||
'diagnostic.goto_next', -- >
|
||||
'buf.code_action', -- a
|
||||
'buf.definition', -- d
|
||||
'buf.declaration', -- D
|
||||
'buf.formatting', -- f
|
||||
'buf.hover', -- h
|
||||
'buf.rename', -- n
|
||||
'buf.references', -- r
|
||||
'buf.document_symbol' -- s
|
||||
}
|
||||
for i = 1, #lspcommands.new do
|
||||
for _,f in pairs(modes_map({'n'})) do
|
||||
f('<Leader>l'..key_pair.new[i],
|
||||
':call LanguageClient'..key_pair.old[i]..'()<CR>', {noremap = true})
|
||||
end
|
||||
}
|
||||
for i = 1, #lsp_commands.new do
|
||||
for _,f in pairs(modes_map({'n'})) do
|
||||
f('<Leader>l'..lsp_commands.new[i],
|
||||
'<cmd>lua vim.lsp.'..lsp_commands.old[i]..'()<CR>',
|
||||
{noremap = true}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
120
lua/native-lsp/init.lua
Normal file
120
lua/native-lsp/init.lua
Normal file
|
@ -0,0 +1,120 @@
|
|||
-- see `:help` for any questions
|
||||
-- use `&<var>` to show value of vimscript variable
|
||||
|
||||
|
||||
-- API --
|
||||
-- o = vim.o -- options
|
||||
-- go = vim.go -- only-global options
|
||||
-- bo = vim.bo -- buffer local options
|
||||
-- wo = vim.wo -- window local options
|
||||
|
||||
-- cmd = vim.cmd -- vim commands
|
||||
-- fn = vim.fn -- vim functions
|
||||
-- opt = vim.opt -- vim option object
|
||||
|
||||
-- g = vim.g -- global variables
|
||||
-- b = vim.b -- buffer local variables
|
||||
-- w = vim.w -- window local variables
|
||||
-- t = vim.t -- tab local variables
|
||||
-- v = vim.v -- variables
|
||||
-- env = vim.env -- environment variables
|
||||
|
||||
|
||||
lspconfig = require 'lspconfig' -- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
|
||||
--local lspfuzzy = require 'lspfuzzy'
|
||||
|
||||
-- Uncomment conflicting or not preferred lines
|
||||
-- lazy loading based on filetype
|
||||
cmd('autocmd BufEnter *.adb,*.ads lua lspconfig.als.setup {}')
|
||||
cmd('autocmd BufEnter *.ts,*.html lua lspconfig.angularls.setup {}')
|
||||
cmd('autocmd BufEnter *.yaml lua lspconfig.ansiblels.setup {}')
|
||||
cmd('autocmd BufEnter *.sh,*.ash,*.bash,*.bsh lua lspconfig.bashls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.beancount.setup {}')
|
||||
cmd('autocmd BufEnter *.bicep lua lspconfig.bicep.setup {}')
|
||||
cmd('autocmd BufEnter *.c,*.h,*.cpp,*.hpp,*.m,*.mm,*.M lua lspconfig.ccls.setup {}')
|
||||
cmd('autocmd BufEnter *.c,*.h,*.cpp,*.hpp,*.m,*.mm,*.M,*.rs,*.f,*.for,*.f90 lua lspconfig.clangd.setup {}')
|
||||
cmd('autocmd BufEnter *.clj,*.cljs lua lspconfig.clojure_lsp.setup {}')
|
||||
cmd('autocmd BufEnter Makefile* lua lspconfig.cmake.setup {}')
|
||||
cmd('autocmd BufEnter *.ql,*.qll lua lspconfig.codeqlls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.configs.setup {}')
|
||||
cmd('autocmd BufEnter *.cr lua lspconfig.crystalline.setup {}')
|
||||
cmd('autocmd BufEnter *.css lua lspconfig.cssls.setup {}')
|
||||
cmd('autocmd BufEnter *.dart lua lspconfig.dartls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.denols.setup {}')
|
||||
cmd('autocmd BufEnter *.dhall lua lspconfig.dhall_lsp_server.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.diagnosticls.setup {}')
|
||||
cmd('autocmd BufEnter *.dockerfile lua lspconfig.dockerls.setup {}')
|
||||
cmd('autocmd BufEnter *.dot,*.gv lua lspconfig.dotls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.efm.setup {}')
|
||||
cmd('autocmd BufEnter *.ex,*.exs lua lspconfig.elixirls.setup {}')
|
||||
cmd('autocmd BufEnter *.elm lua lspconfig.elmls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.ember.setup {}')
|
||||
cmd('autocmd BufEnter *.erl,*hrl lua lspconfig.erlangls.setup {}')
|
||||
cmd('autocmd BufEnter *.js,*.cjs,*.mjs lua lspconfig.flow.setup {}')
|
||||
cmd('autocmd BufEnter *.f*.for,*.f90 lua lspconfig.fortls.setup {}')
|
||||
cmd('autocmd BufEnter *.fs,*.fsi,*.fsx,*.fsscript lua lspconfig.fsautocomplete.setup {}')
|
||||
cmd('autocmd BufEnter *.gd lua lspconfig.gdscript.setup {}')
|
||||
cmd('autocmd BufEnter *.hs,*.lhs lua lspconfig.ghcide.setup {}')
|
||||
cmd('autocmd BufEnter *.go lua lspconfig.gopls.setup {}')
|
||||
cmd('autocmd BufEnter *.graphql lua lspconfig.graphql.setup {}')
|
||||
cmd('autocmd BufEnter *.groovy,*.gvy,*.gy,*.gsh lua lspconfig.groovyls.setup {}')
|
||||
cmd('autocmd BufEnter *.hx,*.hxml lua lspconfig.haxe_language_server.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.health.setup {}')
|
||||
cmd('autocmd BufEnter *.hs,lhs lua lspconfig.hie.setup {}')
|
||||
cmd('autocmd BufEnter *.hs,*.lhs lua lspconfig.hls.setup {}')
|
||||
cmd('autocmd BufEnter *.html,*.htm lua lspconfig.html.setup {}')
|
||||
cmd('autocmd BufEnter *.php,*.phar,*.phtml,*.pht,*.phps lua lspconfig.intelephense.setup {}')
|
||||
cmd('autocmd BufEnter *.java,*.jar,*.class lua lspconfig.java_language_server.setup {}')
|
||||
cmd('autocmd BufEnter *.java,*.jar,*.class lua lspconfig.jdtls.setup {}')
|
||||
cmd('autocmd BufEnter *.py,*.pyi,*.pyc,*pyd lua lspconfig.jedi_language_server.setup {}')
|
||||
cmd('autocmd BufEnter *.json lua lspconfig.jsonls.setup {}')
|
||||
cmd('autocmd BufEnter *.jl lua lspconfig.julials.setup {}')
|
||||
cmd('autocmd BufEnter *.kt,*.kts,*.ktm lua lspconfig.kotlin_language_server.setup {}')
|
||||
cmd('autocmd BufEnter *.lean lua lspconfig.lean3ls.setup {}')
|
||||
cmd('autocmd BufEnter *.lean lua lspconfig.leanls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.lspinfo.setup {}')
|
||||
cmd('autocmd BufEnter *.scala,*.sc lua lspconfig.metals.setup {}')
|
||||
cmd('autocmd BufEnter *.nim,*.nims,*nimble lua lspconfig.nimls.setup {}')
|
||||
cmd('autocmd BufEnter *.ml,*.mli,*.re,*rei lua lspconfig.ocamlls.setup {}')
|
||||
cmd('autocmd BufEnter *.ml,*.mli,*.re,*rei lua lspconfig.ocamllsp.setup {}')
|
||||
cmd('autocmd BufEnter *.cs,*.csx,*.vb,*.vbs,*.vbe,*.wsf,*.wsc lua lspconfig.omnisharp.setup {}')
|
||||
cmd('autocmd BufEnter *.plx,*.pl,*.pm,*.xs,*.t lua lspconfig.perlls.setup {}')
|
||||
cmd('autocmd BufEnter *.plx,*.pl,*.pm,*.xs,*.t lua lspconfig.perlpls.setup {}')
|
||||
cmd('autocmd BufEnter *.php,*.phar,*.phtml,*.pht,*.phps lua lspconfig.phpactor.setup {}')
|
||||
cmd('autocmd BufEnter *.ps,*.ps1,*.ps1xml,*.psc1,*.psd1,*.psm1,*.pssc,*.psrc,*.cdxml lua lspconfig.powershell_es.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.prismals.setup {}')
|
||||
cmd('autocmd BufEnter *.pp lua lspconfig.puppet.setup {}')
|
||||
cmd('autocmd BufEnter *.purs lua lspconfig.purescriptls.setup {}')
|
||||
cmd('autocmd BufEnter *.py,*.pyi,*.pyc,*pyd lua lspconfig.pylsp.setup {}')
|
||||
cmd('autocmd BufEnter *.py,*.pyi,*.pyc,*pyd lua lspconfig.pyright.setup {}')
|
||||
cmd('autocmd BufEnter *.r,*.rdata,*.rds,*.rda,*.rmd lua lspconfig.r_language_server.setup {}')
|
||||
cmd('autocmd BufEnter *.rkt,*.scm,*.ss lua lspconfig.racket_langserver.setup {}')
|
||||
cmd('autocmd BufEnter *.re,*rei lua lspconfig.rescriptls.setup {}')
|
||||
cmd('autocmd BufEnter *.rs,*.rlib lua lspconfig.rls.setup {}')
|
||||
cmd('autocmd BufEnter *.nix lua lspconfig.rnix.setup {}')
|
||||
cmd('autocmd BufEnter *.js,*.cjs,*.mjs,*.json,*.ts,*.tsx lua lspconfig.rome.setup {}')
|
||||
cmd('autocmd BufEnter *.rs,*.rlib lua lspconfig.rust_analyzer.setup {}')
|
||||
cmd('autocmd BufEnter *.cr lua lspconfig.scry.setup {}')
|
||||
cmd('autocmd BufEnter *.d lua lspconfig.serve_d.setup {}')
|
||||
cmd('autocmd BufEnter *.rb lua lspconfig.solargraph.setup {}')
|
||||
cmd('autocmd BufEnter *.rb lua lspconfig.sorbet.setup {}')
|
||||
cmd('autocmd BufEnter *.swift,*.SWIFT,*.c,*.h,*.cpp,*.hpp,*.m,*.mm,*.M lua lspconfig.sourcekit.setup {}')
|
||||
cmd('autocmd BufEnter *.sql lua lspconfig.sqlls.setup {}')
|
||||
cmd('autocmd BufEnter *.sql lua lspconfig.sqls.setup {}')
|
||||
cmd('autocmd BufEnter *.css,*.less,*.sass,*.scss,*.sss,**.js,*.cjs,*.mjs,*.ts,*.tsx lua lspconfig.stylelint_lsp.setup {}')
|
||||
cmd('autocmd BufEnter *.lua lua lspconfig.sumneko_lua.setup {}')
|
||||
cmd('autocmd BufEnter *.svelte lua lspconfig.svelte.setup {}')
|
||||
cmd('autocmd BufEnter *.v,*.vh,*.sv,*.svh lua lspconfig.svls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.tailwindcss.setup {}') -- uh... what? https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/tailwindcss.lua#L10
|
||||
cmd('autocmd BufEnter *.hcl lua lspconfig.terraformls.setup {}')
|
||||
cmd('autocmd BufEnter *.tex,*.latex,*.bib lua lspconfig.texlab.setup {}')
|
||||
cmd('autocmd BufEnter *.hcl lua lspconfig.tflint.setup {}')
|
||||
cmd('autocmd BufEnter *.ts,*.tsx lua lspconfig.tsserver.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.util.setup {}')
|
||||
cmd('autocmd BufEnter *.vala,*.vali,*.gs lua lspconfig.vala_ls.setup {}')
|
||||
cmd('autocmd BufEnter *.vim lua lspconfig.vimls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.vls.setup {}')
|
||||
--cmd('autocmd BufEnter lua lspconfig.vuels.setup {}')
|
||||
cmd('autocmd BufEnter *.yaml lua lspconfig.yamlls.setup {}')
|
||||
cmd('autocmd BufEnter *.md lua lspconfig.zeta_note.setup {}')
|
||||
cmd('autocmd BufEnter *.zig,*.zir lua lspconfig.zls.setup {}')
|
Loading…
Reference in a new issue