feat: configure LSP in neovim

add LSP config in $XDG_CONFIG_HOME/nvim/lua/lsp
add language servers:
        - clangd (C/C++)
        - jedi (Python)
This commit is contained in:
David JULIEN 2021-05-19 00:53:42 +02:00
parent 8ec80d78f5
commit 32680ec340
9 changed files with 95 additions and 0 deletions

View File

@ -9,3 +9,9 @@ require("maps") -- ./lua/maps.lua
require("statusline") -- ./lua/statusline.lua
require("polyjuice") -- colorscheme
-- LSP
require("lsp") -- ./lua/lsp/init.lua
require("lsp.maps") -- ./lua/lsp/maps.lua
require("lsp.c") -- ./lua/lsp/c.lua
require("lsp.python") -- ./lua/lsp/python.lua

View File

@ -0,0 +1,6 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : clangd config file for lsp
require("lspconfig").clangd.setup {}

View File

@ -0,0 +1,21 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : neovim lsp config file
vim.fn.sign_define(
"LspDiagnosticsSignError",
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}
)
vim.fn.sign_define(
"LspDiagnosticsSignWarning",
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}
)
vim.fn.sign_define(
"LspDiagnosticsSignHint",
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}
)
vim.fn.sign_define(
"LspDiagnosticsSignInformation",
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}
)

View File

@ -0,0 +1,39 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : sumneko (lua) config file for lsp
local system_name = "Linux"
-- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use
local sumneko_root_path = vim.fn.stdpath('cache')..'/lspconfig/sumneko_lua/lua-language-server'
local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server"
require'lspconfig'.sumneko_lua.setup {
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
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,
},
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}

View File

@ -0,0 +1,11 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : neovim lsp mappings file
utils = require("utils")
utils.map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>")
utils.map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>")
utils.map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
utils.map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")

View File

@ -0,0 +1,6 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 15:03:43 CET
-- License : GPLv3
-- Description : jedi (python) config file for lsp
require("lspconfig").jedi_language_server.setup{}

View File

@ -35,6 +35,9 @@ return require("packer").startup(function()
cmd = {"Telescope"}
}
-- LSP
use "neovim/nvim-lspconfig"
-- display colors directly in editor
use {
"norcalli/nvim-colorizer.lua",

View File

@ -36,6 +36,7 @@ o.background = "dark"
o.shortmess = o.shortmess .. "c"
w.number = true
w.relativenumber = true
w.signcolumn = "yes"
o.listchars = "tab:<->,nbsp:␣,trail:·,extends:>,precedes:<"
o.showmatch = true
o.ignorecase = true

View File

@ -16,6 +16,7 @@ binutils
bison
capitaine-cursors
cdparanoia
clang
cmake
cronie
dash
@ -40,6 +41,7 @@ iftop
imagemagick
isync
iwd
jedi-language-server
libnotify
libtool
linux