nvim-lsp-installer, nvim-cmp, and other plugins
Other plugins: - gitsigns - lightbulb - indent-blankline - treesitter - light theme Removed lsp install scripts b/c of nvim-lsp-installer
This commit is contained in:
parent
f6d4e367d2
commit
f81c4bde28
19 changed files with 429 additions and 259 deletions
|
@ -19,163 +19,23 @@
|
|||
-- v = vim.v -- variables
|
||||
-- env = vim.env -- environment variables
|
||||
|
||||
-- dependent on https://github.com/neovim/nvim-lspconfig
|
||||
local lspconfig = require 'lspconfig'
|
||||
require("native-lsp/nvim-lsp-installer")
|
||||
|
||||
function lsp_init()
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
|
||||
local lsp_filetype = {
|
||||
['ada'] = {'als'},
|
||||
['aspnetcorerazor'] = {'tailwindcss'},
|
||||
['astro'] = {'tailwindcss'},
|
||||
['astro-markdown'] = {'tailwindcss'},
|
||||
['beancount'] = {'beancount'},
|
||||
['bib'] = {'texlab'},
|
||||
['bicep'] = {'bicep'},
|
||||
['blade'] = {'tailwindcss'},
|
||||
['c'] = {'ccls','clangd','sourcekit'},
|
||||
['clojure'] = {'clojure_lsp'},
|
||||
['cmake'] = {'cmake'},
|
||||
-- = {'config'},
|
||||
['cpp'] = {'ccls','clangd','sourcekit'},
|
||||
['crystal'] = {'crystalline','scry'},
|
||||
['css'] = {'cssls','stylelint_lsp','tailwindcss'},
|
||||
['d'] = {'serve_d'},
|
||||
['dart'] = {'dartls'},
|
||||
['dhall'] = {'dhall_lsp_server'},
|
||||
['django-html'] = {'tailwindcss'},
|
||||
['Dockerfile'] = {'dockerls'},
|
||||
['dockerfile'] = {'dockerls'},
|
||||
['dot'] = {'dotls'},
|
||||
-- = {'diagnostics'},
|
||||
['edge'] = {'tailwindcss'},
|
||||
['edn'] = {'clojure_lsp'},
|
||||
['eelixir'] = {'elixirls','tailwindcss'},
|
||||
-- = {'efm'},
|
||||
['elixir'] = {'elixirls'},
|
||||
['elm'] = {'elmls'},
|
||||
['ejs'] = {'tailwindcss'},
|
||||
['erb'] = {'tailwindcss'},
|
||||
['erlang'] = {'erlangls'},
|
||||
['eruby'] = {'tailwindcss'},
|
||||
['fortran'] = {'fortls'},
|
||||
['fsharp'] = {'fsautocomplete'},
|
||||
['gd'] = {'gdscript'},
|
||||
['gdscript'] = {'gdscript'},
|
||||
['gdscript3'] = {'gdscript'},
|
||||
['genie'] = {'vala_ls'},
|
||||
['go'] = {'gopls'},
|
||||
['gohtml'] = {'tailwindcss'},
|
||||
['gomod'] = {'gopls'},
|
||||
['graphql'] = {'graphql'},
|
||||
['groovy'] = {'groovyls'},
|
||||
['haml'] = {'tailwindcss'},
|
||||
['handlebars'] = {'ember','tailwindcss'},
|
||||
['haskell'] = {'ghcide','hie','hls'},
|
||||
['haxe'] = {'haxe_language_server'},
|
||||
['hbs'] = {'tailwindcss'},
|
||||
-- = {'health'},
|
||||
['help'] = {},
|
||||
['html'] = {'angular','html','tailwindcss'},
|
||||
['html-eex'] = {'tailwindcss'},
|
||||
['jade'] = {'tailwindcss'},
|
||||
['java'] = {'java_language_server','jdtls'},
|
||||
['javascript'] = {'denols','ember','flow','rome','stylelint_lsp','tsserver','tailwindcss'},
|
||||
['javascriptreact'] = {'denols','flow','rome','stylelint_lsp','tsserver','tailwindcss'},
|
||||
['javascript.jsx'] = {'denols','flow','tsserver'},
|
||||
['json'] = {'jsonls','rome'},
|
||||
['julia'] = {'julials'},
|
||||
['kotlin'] = {'kotlin_language_server'},
|
||||
['leaf'] = {'tailwindcss'},
|
||||
['lean'] = {'leanls'},
|
||||
['lean3'] = {'lean3ls'},
|
||||
['less'] = {'cssls','stylelint_lsp','tailwindcss'},
|
||||
['lhaskell'] = {'ghcide','hls'},
|
||||
-- = {'lspinfo'},
|
||||
['liquid'] = {'tailwindcss'},
|
||||
['lua'] = {'sumneko_lua'},
|
||||
['markdown'] = {'zeta_note','tailwindcss'},
|
||||
['mdx'] = {'tailwindcss'},
|
||||
['mint'] = {'mint'},
|
||||
['mustache'] = {'tailwindcss'},
|
||||
['mysql'] = {'sqlls','sqls'},
|
||||
['nim'] = {'nimls'},
|
||||
['nix'] = {'rnix'},
|
||||
['njk'] = {'tailwindcss'},
|
||||
['nunjucks'] = {'tailwindcss'},
|
||||
['objc'] = {'ccls','clangd'},
|
||||
['objcpp'] = {'ccls','clangd'},
|
||||
['objective-c'] = {'sourcekit'},
|
||||
['objective-cpp'] = {'sourcekit'},
|
||||
['ocaml'] = {'ocamlls','ocamllsp'},
|
||||
['ocaml.menhir'] = {'ocamllsp'},
|
||||
['ocaml.interface'] = {'ocamllsp'},
|
||||
['ocaml.ocamllex'] = {'ocamllsp'},
|
||||
['perl'] = {'perlls','perlpls'},
|
||||
['php'] = {'intelephense','phpactor','tailwindcss'},
|
||||
['prisma'] = {'prismals'},
|
||||
['ps1'] = {'powershell_es'},
|
||||
['puppet'] = {'puppet'},
|
||||
['purescript'] = {'purescriptls'},
|
||||
['python'] = {'jedi_language_server','pylsp','pyright'},
|
||||
['ql'] = {'codeqlls'},
|
||||
['r'] = {'r_language_server'},
|
||||
['racket'] = {'racket_langserver'},
|
||||
['razor'] = {'tailwindcss'},
|
||||
['reason'] = {'ocamlls','ocamllsp','tailwindcss'},
|
||||
['rescript'] = {'rescript','tailwindcss'},
|
||||
['rmd'] = {'r_language_server'},
|
||||
['ruby'] = {'solargraph','sorbet'},
|
||||
['rust'] = {'rls','rust_analyzer'},
|
||||
['sass'] = {'tailwindcss'},
|
||||
['scala'] = {'metals'},
|
||||
['scheme'] = {'racket_langserver'},
|
||||
['scss'] = {'cssls','stylelint_lsp','tailwindcss'},
|
||||
['sh'] = {'bashls'},
|
||||
['slim'] = {'tailwindcss'},
|
||||
['stylus'] = {'tailwindcss'},
|
||||
['sql'] = {'sqlls','sqls'},
|
||||
['sugarss'] = {'stylelint_lsp','tailwindcss'},
|
||||
['svelte'] = {'svelte','tailwindcss'},
|
||||
['swift'] = {'source'},
|
||||
['systemverilog'] = {'svls'},
|
||||
['tex'] = {'texlab'},
|
||||
['terraform'] = {'tflint','teraformls'},
|
||||
['twig'] = {'tailwindcss'},
|
||||
['typescript'] = {'angular', 'denols','ember','rome','stylelint_lsp','tsserver','tailwindcss'},
|
||||
['typescriptreact'] = {'angular', 'denols','rome','stylelint_lsp','tsserver','tailwindcss'},
|
||||
['typescript.tsx'] = {'angular', 'denols','rome','tsserver'},
|
||||
-- = {'util'},
|
||||
['vala'] = {'vala_ls'},
|
||||
['verilog'] = {'svls'},
|
||||
['vim'] = {'vimls'},
|
||||
['vlang'] = {'vls'},
|
||||
['vue'] = {'stylelint_lsp','vuels','tailwindcss'},
|
||||
['wxss'] = {'stylelint_lsp'},
|
||||
['yaml'] = {'ansiblels','yamlls'},
|
||||
['zig'] = {'zls'},
|
||||
['zir'] = {'zls'}
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
local on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
require('completion').on_attach()
|
||||
end
|
||||
|
||||
local servers = {'zls'}
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
for _,server in pairs(lsp_filetype[bo.filetype]) do
|
||||
lspconfig[server].setup {}
|
||||
end
|
||||
end
|
||||
|
||||
function lsp_format()
|
||||
local function format_file()
|
||||
if bo.filetype == x then
|
||||
vim.lsp.formatting_sync(nil, 100)
|
||||
end
|
||||
end
|
||||
opt.completeopt = "menu,menuone,noselect"
|
||||
g.completion_enable_auto_popup = 1
|
||||
|
||||
for _,file in pairs({'javascript', 'python'}) do
|
||||
format_file(file)
|
||||
end
|
||||
end
|
||||
|
||||
cmd('autocmd BufRead * lua lsp_init()')
|
||||
cmd('autocmd BufWritePre * lua lsp_format()')
|
||||
|
||||
|
||||
require 'nvim-compe.lua'
|
||||
require("native-lsp/nvim-cmp")
|
||||
|
|
154
lua/native-lsp/nvim-cmp.lua
Normal file
154
lua/native-lsp/nvim-cmp.lua
Normal file
|
@ -0,0 +1,154 @@
|
|||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
if not luasnip then
|
||||
return
|
||||
end
|
||||
|
||||
local lsp_symbols = {
|
||||
Text = " (Text) ",
|
||||
Method = " (Method)",
|
||||
Function = " (Function)",
|
||||
Constructor = " (Constructor)",
|
||||
Field = " ﴲ (Field)",
|
||||
Variable = " (Variable)",
|
||||
Class = " (Class)",
|
||||
Interface = " (Interface)",
|
||||
Module = " (Module)",
|
||||
Property = " 襁 (Property)",
|
||||
Unit = " (Unit)",
|
||||
Value = " (Value)",
|
||||
Enum = " 練 (Enum)",
|
||||
Keyword = " (Keyword)",
|
||||
Snippet = " (Snippet)",
|
||||
Color = " (Color)",
|
||||
File = " (File)",
|
||||
Reference = " (Reference)",
|
||||
Folder = " (Folder)",
|
||||
EnumMember = " (EnumMember)",
|
||||
Constant = " (Constant)",
|
||||
Struct = " (Struct)",
|
||||
Event = " (Event)",
|
||||
Operator = " (Operator)",
|
||||
TypeParameter = " (TypeParameter)"
|
||||
}
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
mapping = {
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
["<C-n>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-e>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<C-CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format = function(entry, item)
|
||||
item.kind = lsp_symbols[item.kind] .. " " .. item.kind
|
||||
-- set a name for each source
|
||||
item.menu = ({
|
||||
spell = "[Spell]",
|
||||
buffer = "[Buffer]",
|
||||
calc = "[Calc]",
|
||||
emoji = "[Emoji]",
|
||||
nvim_lsp = "[LSP]",
|
||||
path = "[Path]",
|
||||
look = "[Look]",
|
||||
treesitter = "[treesitter]",
|
||||
luasnip = "[LuaSnip]",
|
||||
nvim_lua = "[Lua]",
|
||||
latex_symbols = "[Latex]",
|
||||
cmp_tabnine = "[Tab9]"
|
||||
})[entry.source.name]
|
||||
return item
|
||||
end
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'cmp_tabnine' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'latex_symbols'},
|
||||
{ name = 'treesitter' },
|
||||
{ name = 'buffer' },
|
||||
{
|
||||
name = 'look',
|
||||
keyword_length = 2,
|
||||
option = {
|
||||
convert_case = true,
|
||||
loud = true
|
||||
}
|
||||
},
|
||||
{ name = 'emoji' },
|
||||
{ name = 'calc' }
|
||||
},
|
||||
|
||||
cmp.setup.cmdline('-', {
|
||||
sources = {
|
||||
{ name = 'path' },
|
||||
{ name = 'cmdline' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
}),
|
||||
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
}),
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
}),
|
||||
})
|
||||
|
||||
local tabnine = require('cmp_tabnine.config')
|
||||
|
||||
tabnine:setup({
|
||||
max_lines = 1000;
|
||||
max_num_results = 20;
|
||||
sort = true;
|
||||
run_on_every_keystroke = true;
|
||||
snippet_placeholder = '..';
|
||||
ignored_file_types = { -- default is not to ignore
|
||||
-- uncomment to ignore in lua:
|
||||
-- lua = true
|
||||
};
|
||||
})
|
75
lua/native-lsp/nvim-lsp-installer.lua
Normal file
75
lua/native-lsp/nvim-lsp-installer.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
local lsp_installer = require("nvim-lsp-installer")
|
||||
|
||||
|
||||
local lang_servers = {
|
||||
"bashls",
|
||||
"ccls",
|
||||
"clangd",
|
||||
"cmake",
|
||||
"cssls",
|
||||
"cssmodules_ls",
|
||||
"diagnosticls",
|
||||
"dockerls",
|
||||
"dotls",
|
||||
"efm",
|
||||
--"eslint",
|
||||
"emmet_ls",
|
||||
--"grammarly",
|
||||
"graphql",
|
||||
"html",
|
||||
--"hls",
|
||||
"jsonls",
|
||||
--"jdtls",
|
||||
--"quick_lint_js",
|
||||
"tsserver",
|
||||
--"ltex",
|
||||
"texlab",
|
||||
"sumneko_lua",
|
||||
"remark_ls",
|
||||
--"zk",
|
||||
"puppet",
|
||||
--"jedi_language_server",
|
||||
"pyright",
|
||||
--"pylsp",
|
||||
"sqlls",
|
||||
--"sqls",
|
||||
--"svelte",
|
||||
"taplo",
|
||||
--"tailwindcss",
|
||||
--"tflint", -- going to use tsserver first
|
||||
"lemminx",
|
||||
"yamlls",
|
||||
"zls",
|
||||
}
|
||||
|
||||
for _, name in pairs(lang_servers) do
|
||||
local server_is_found, server = lsp_installer.get_server(name)
|
||||
if server_is_found then
|
||||
if not server:is_installed() then
|
||||
print("Installing " .. name)
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
lsp_installer.on_server_ready(function(server)
|
||||
local opts = {}
|
||||
opts.on_attach = on_attach
|
||||
opts.capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
server:setup(opts)
|
||||
vim.cmd [[ do User LspAttachBuffers ]]
|
||||
end)
|
||||
|
||||
|
||||
lsp_installer.settings({
|
||||
ui = {
|
||||
icons = {
|
||||
server_installed = "✓",
|
||||
server_pending = "➜",
|
||||
server_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue