Merge branch 'dev' into mercury

dwm: update to 6.3 (fresh restart)
nvim: update to 0.7
    change keymap API
    update LSP installation
    lua tabstop=8->4
    remove unused plugins
This commit is contained in:
David JULIEN 2022-04-27 22:47:51 +02:00
commit ce0709a0b1
Signed by: swytch
GPG Key ID: 498590A3AA82A06F
20 changed files with 658 additions and 668 deletions

View File

@ -7,3 +7,4 @@ local opt = vim.opt
local g = vim.g local g = vim.g
opt.formatoptions = "trq1jp" opt.formatoptions = "trq1jp"
opt.tabstop = 4

View File

@ -5,7 +5,6 @@
local opt = vim.opt local opt = vim.opt
local g = vim.g
opt.formatoptions = "trq1jp" opt.formatoptions = "trq1jp"
opt.tabstop = 4 opt.tabstop = 4

View File

@ -6,8 +6,6 @@
local M = {} -- The module to export local M = {} -- The module to export
M = { M = {
lsp_path = vim.fn.stdpath("data").. "/lsp",
-- misc -- misc
sign_error = "", sign_error = "",
sign_warning = "", sign_warning = "",

View File

@ -1,20 +0,0 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : clangd config file for lsp
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
require("lspconfig").clangd.setup {
cmd = { "clangd",
"--background-index",
"--suggest-missing-includes",
"--clang-tidy",
"--header-insertion=iwyu"
},
-- The following example advertise capabilities to `clangd`.
capabilities = capabilities,
}

View File

@ -1,80 +0,0 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : neovim lsp config file
local M = {}
vim.fn.sign_define(
"DiagnosticSignError",
{
texthl = "DiagnosticVirtualTextError",
text = globals.sign_error,
numhl = "DiagnosticSignError"
}
)
vim.fn.sign_define(
"DiagnosticSignWarn",
{
texthl = "DiagnosticVirtualTextWarn",
text = globals.sign_warning,
numhl = "DiagnosticSignWarn"
}
)
vim.fn.sign_define(
"DiagnosticSignHint",
{
texthl = "DiagnosticVirtualTextHint",
text = globals.sign_hint,
numhl = "DiagnosticSignHint"
}
)
vim.fn.sign_define(
"DiagnosticSignInfo",
{
texthl = "DiagnosticVirtualTextInfo",
text = globals.sign_info,
numhl = "DiagnosticSignInfo"
}
)
M.icons = {
Class = "",
Color = "",
Constant = " µ ",
Constructor = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Keyword = "",
Interface = "",
Method = "",
Module = "",
Operator = "",
Property = "",
Reference = "",
Snippet = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
}
function M.setup()
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = M.icons[kind] or kind
end
local ft = vim.bo.filetype
if ft == "cpp" then ft = "c" end
require("lsp." .. ft) -- ./<ft>.lua
end
return M

View File

@ -1,40 +0,0 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : sumneko (lua) config file for lsp
-- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use
local sumneko_root_path = vim.fn.stdpath("data") ..
"/lsp_servers/sumneko_lua/extension/server"
local sumneko_binary = sumneko_root_path .. "/bin/" .. "/lua-language-server"
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
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 = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {"vim", "use", "globals", "utils"},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}

View File

@ -1,8 +0,0 @@
-- 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{
cmd = { vim.fn.stdpath("data") .. "/lsp_servers/jedi_language_server/venv/bin/jedi-language-server" }
}

View File

@ -1,13 +0,0 @@
-- Author : swytch
-- Created : Saturday May 23, 2021 10:34:53 CET
-- License : GPLv3
-- Description : LaTeX config file for lsp
require("lspconfig").texlab.setup {
cmd = { vim.fn.stdpath("data") .. "/lsp_servers/latex/texlab" },
settings = {
build = {
executable = "pdflatex"
}
}
}

View File

@ -3,30 +3,31 @@
-- License : GPLv3 -- License : GPLv3
-- Description : neovim mappings file -- Description : neovim mappings file
utils.map("n", "<space>", "<leader>") vim.keymap.set({ "n", "v" }, "<space>", "<Nop>", { silent = true })
utils.map("n", "<leader>y", "\"+y") vim.g.mapleader = " "
utils.map("n", "<leader>p", "\"+P")
utils.map("n", "<leader><enter>", "<cmd>w! | !compiler %<CR>")
utils.map("n", "<leader>u", "<cmd>PackerSync<CR>")
utils.map("n", "<leader>c", "<cmd>ColorizerToggle<CR>")
-- LSP -- Dealing with word wrap
utils.map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>") vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'",
utils.map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>") { expr = true, silent = true })
utils.map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>") vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'",
utils.map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>") { expr = true, silent = true })
utils.map("n", "<leader>ln", "<cmd>lua vim.diagnostic.goto_next()<CR>")
utils.map("n", "<leader>lp", "<cmd>lua vim.diagnostic.goto_prev()<CR>") vim.keymap.set("n", "<leader>y", "\"+y")
utils.map("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>") vim.keymap.set("n", "<leader>p", "\"+P")
vim.keymap.set("n", "<leader><enter>", "<cmd>w! | !compiler %<CR>")
vim.keymap.set("n", "<leader>u", function() require("packer").sync() end)
-- telescope -- telescope
utils.map("n", "<leader>ff", "<cmd>Telescope find_files<CR>") vim.keymap.set("n", "<leader>ff",
utils.map("n", "<leader>fb", "<cmd>Telescope buffers<CR>") function() require("telescope.builtin").find_files() end)
utils.map("n", "<leader>fl", "<cmd>Telescope live_grep<CR>") vim.keymap.set("n", "<leader>fb",
function() require("telescope.builtin").buffers() end)
vim.keymap.set("n", "<leader>fl",
function() require("telescope.builtin").live_grep() end)
-- colorscheme -- colorscheme
utils.map("n", "<C-s>", "<cmd>lua require(\"astronomy\").toggle_variant()<CR>") vim.keymap.set("n", "<C-s>",
function() require("astronomy").toggle_variant() end)
-- snippets -- snippets
utils.map("i", "<C-E>", "<Plug>luasnip-next-choice", {}) vim.keymap.set({ "i", "s" }, "<C-E>", "<Plug>luasnip-next-choice")
utils.map("s", "<C-E>", "<Plug>luasnip-next-choice", {})

View File

@ -0,0 +1,77 @@
-- Author : swytch
-- Created : Tuesday May 18, 2021 12:08:51 CET
-- License : GPLv3
-- Description : neovim lsp config file
local M = {}
vim.fn.sign_define(
"DiagnosticSignError",
{
texthl = "DiagnosticVirtualTextError",
text = globals.sign_error,
numhl = "DiagnosticSignError"
}
)
vim.fn.sign_define(
"DiagnosticSignWarn",
{
texthl = "DiagnosticVirtualTextWarn",
text = globals.sign_warning,
numhl = "DiagnosticSignWarn"
}
)
vim.fn.sign_define(
"DiagnosticSignHint",
{
texthl = "DiagnosticVirtualTextHint",
text = globals.sign_hint,
numhl = "DiagnosticSignHint"
}
)
vim.fn.sign_define(
"DiagnosticSignInfo",
{
texthl = "DiagnosticVirtualTextInfo",
text = globals.sign_info,
numhl = "DiagnosticSignInfo"
}
)
M.icons = {
Class = "",
Color = "",
Constant = " µ ",
Constructor = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Keyword = "",
Interface = "",
Method = "",
Module = "",
Operator = "",
Property = "",
Reference = "",
Snippet = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
}
function M.setup()
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = M.icons[kind] or kind
end
end
return M

View File

@ -9,20 +9,18 @@ lsp_installer.settings {
ui = { ui = {
icons = { icons = {
server_installed = "", server_installed = "",
server_pending = "", server_pending = "o",
server_uninstalled = "" server_uninstalled = "x"
} }
} }
} }
local servers = { local servers = {
"bashls", "clangd",
"jedi_language_server",
"texlab",
"sumneko_lua", "sumneko_lua",
} }
for _, name in pairs(servers) do for _, name in ipairs(servers) do
local ok, server = lsp_installer.get_server(name) local ok, server = lsp_installer.get_server(name)
-- Check that the server is supported in nvim-lsp-installer -- Check that the server is supported in nvim-lsp-installer
if ok then if ok then
@ -33,15 +31,99 @@ for _, name in pairs(servers) do
end end
end end
local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/"
local runtime_path = vim.split(package.path, ';')
local clangd_binary = lsp_root_path .. "clangd/clangd/bin/clangd"
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
local enhance_server_opts = {
["clangd"] = function(opts)
opts.settings = {
cmd = { clangd_binary,
"--background-index",
"--suggest-missing-includes",
"--clang-tidy",
"--header-insertion=iwyu"
},
}
end,
["sumneko_lua"] = function(opts)
opts.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 = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {
"vim",
"globals",
"utils"
},
},
workspace = {
-- Make the server aware of Neovim runtime files
library =
vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but
-- unique identifier
telemetry = {
enable = false,
},
},
}
end,
}
local on_attach = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<leader>ln", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.formatting, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<leader>wa",
vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<leader>wr",
vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<leader>wl", function()
vim.inspect(vim.lsp.buf.list_workspace_folders())
end, opts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>so",
require("telescope.builtin").lsp_document_symbols, opts)
end
-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
lsp_installer.on_server_ready(function(server) lsp_installer.on_server_ready(function(server)
local opts = {} -- Specify the default options which we'll use to setup all servers
local opts = {
on_attach = on_attach,
capabilities = capabilities,
}
-- (optional) Customize the options passed to the server if enhance_server_opts[server.name] then
-- if server.name == "tsserver" then -- Enhance the default opts with the server-specific ones
-- opts.root_dir = function() ... end enhance_server_opts[server.name](opts)
-- end end
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
server:setup(opts) server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
end) end)

View File

@ -4,16 +4,23 @@
-- Description : neovim plugins file -- Description : neovim plugins file
local execute = vim.api.nvim_command local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
local fn = vim.fn if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
print("Cloning packer...")
local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" PACKER_BOOTSTRAP = vim.fn.system({
"git",
if fn.empty(fn.glob(install_path)) > 0 then "clone",
fn.system({"git", "clone", "https://github.com/wbthomason/packer.nvim", install_path}) "--depth",
execute "packadd packer.nvim" "1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
vim.cmd([[packadd packer.nvim]])
print("Done.")
end end
local use = require("packer").use
return require("packer").startup(function() return require("packer").startup(function()
-- packer manages itself -- packer manages itself
use "wbthomason/packer.nvim" use "wbthomason/packer.nvim"
@ -34,34 +41,26 @@ return require("packer").startup(function()
-- fuzzy finder -- fuzzy finder
use { use {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
opt = true,
requires = { requires = {
{ {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
opt = true
}, },
{'nvim-telescope/telescope-fzf-native.nvim', {
opt = true, "nvim-telescope/telescope-fzf-native.nvim",
run = 'make' run = "make"
} }
}, },
cmd = "Telescope"
} }
-- LSP -- LSP
use { use {
"williamboman/nvim-lsp-installer", "williamboman/nvim-lsp-installer",
cmd = { requires = {
"LspInstall",
"LspInstallInfo"
},
config = function() require("plugin.lsp_installer").setup() end
}
use {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
ft = { "c", "cpp", "lua", "python", "tex"}, config = function()
config = function() require("lsp").setup() end require("plugin.lsp_config").setup() end
},
config = function() require("plugin.lsp_installer") end
} }
-- auto completion -- auto completion
@ -94,12 +93,12 @@ return require("packer").startup(function()
-- autopairs -- autopairs
use { use {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
config = function() require('nvim-autopairs').setup() end config = function() require("nvim-autopairs").setup() end
} }
-- display colors directly in editor
use { -- automatically setup the config after cloning
"norcalli/nvim-colorizer.lua", if PACKER_BOOTSTRAP then
cmd = "ColorizerToggle" require("packer").sync()
} end
end) end)

View File

@ -4,7 +4,7 @@
-- Description : treesitter config file -- Description : treesitter config file
require("nvim-treesitter.configs").setup { require("nvim-treesitter.configs").setup {
ensure_installed = { "c", "lua", "python", "bash", "latex", "verilog" }, ensure_installed = { "c", "lua", "python", "bash" },
ignore_install = { "javascript" }, ignore_install = { "javascript" },
highlight = { highlight = {
enable = true, enable = true,

View File

@ -121,29 +121,29 @@ local function get_lsp_diagnostics(bufnr)
end end
local function process_diagnostics(prefix, n, hl) local function process_diagnostics(prefix, n, hl)
if n > 0 then if n > 0 then
return hl .. prefix .. n return hl .. prefix .. n
else else
return "" return ""
end end
end end
local function spell_check() local function spell_check()
if vim.wo.spell then if vim.wo.spell then
local lang = vim.o.spelllang local lang = vim.o.spelllang
return "[SPELL=" .. lang .. "]" return "[SPELL=" .. lang .. "]"
else else
return "" return ""
end end
end end
local function statusline_focused() local function statusline_focused()
local diagnostics = get_lsp_diagnostics() local diagnostics = get_lsp_diagnostics()
local mode = vim.fn.mode() local mode = vim.fn.mode()
local mg = get_mode(mode) local mg = get_mode(mode)
local accent_color = get_mode_color(mg) local accent_color = get_mode_color(mg)
local left = table.concat { local left = table.concat {
gen_section(accent_color, {get_mode_display_name(mg)}), gen_section(accent_color, {get_mode_display_name(mg)}),
gen_section("%#Middle#", {"%f"}), gen_section("%#Middle#", {"%f"}),
gen_section("%#Bottom#", {"%m", "%r"}), gen_section("%#Bottom#", {"%m", "%r"}),
@ -167,8 +167,8 @@ local function statusline_focused()
) )
} }
) )
} }
local right = table.concat { local right = table.concat {
gen_section( gen_section(
"%#Bottom#", "%#Bottom#",
{ {
@ -178,14 +178,14 @@ local function statusline_focused()
), ),
gen_section("%#Middle#", {"%03.p%%"}), gen_section("%#Middle#", {"%03.p%%"}),
gen_section("%#Top#", {"-%03.c-"}) gen_section("%#Top#", {"-%03.c-"})
} }
return table.concat { return table.concat {
left, left,
"%#Statusline#", "%#Statusline#",
"%=", "%=",
right right
} }
end end

View File

@ -22,12 +22,6 @@ function M.add_rtp(path)
rtp = rtp .. "," .. path rtp = rtp .. "," .. path
end end
-- map a key with optional options
function M.map(mode, keys, action, options)
options = options or {}
vim.api.nvim_set_keymap(mode, keys, action, options)
end
-- see if a file exists -- see if a file exists
function M.file_exists(file) function M.file_exists(file)
local f = io.open(file, "rb") local f = io.open(file, "rb")

@ -1 +1 @@
Subproject commit f8ad07e02878adfbdab1241869630d608566c5c0 Subproject commit 82003c8dad7b966ab65f339749fb4272eafb8f4b