This commit is contained in:
mokou 2022-03-13 23:07:52 +01:00
parent 99c942cc3b
commit 618a1e6841
8 changed files with 87 additions and 141 deletions

View file

@ -3,3 +3,7 @@
require("options")
require("utils")
require("plugins")
-- Initialize all of the boring plugins
require("rust-tools").setup({})
require("fidget").setup({})

View file

@ -19,4 +19,19 @@ return require("packer").startup(function(use)
-- LSP stuff
use({"neovim/nvim-lspconfig", config = function() require("plugins.lsp") end})
use "simrat39/rust-tools.nvim"
use "stevearc/aerial.nvim"
use "j-hui/fidget.nvim"
-- Completion
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-path"
use "hrsh7th/cmp-cmdline"
use({"hrsh7th/nvim-cmp", config = function() require("plugins.completion") end})
-- Fancy UI stuff
use "RRethy/nvim-base16"
use "stevearc/dressing.nvim"
end)

View file

@ -0,0 +1,37 @@
local cmp = require("cmp")
cmp.setup({
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), {"i", "c"}),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{name = "nvim_lsp"},
}, {
{name = "buffer"},
}),
})
cmp.setup.cmdline(":", {
sources = cmp.config.sources({
{name = "path"},
}, {
{name = "buffer"},
}),
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lsps = {"sumneko_lua", "rust_analyzer"}
for _, lsp in pairs(lsps) do
require('lspconfig')[lsp].setup {
capabilities = capabilities
}
end

View file

@ -9,7 +9,7 @@ Utils.nmap("]d", "<cmd>lua vim.diagnostic.goto_next()<CR>")
Utils.nmap("<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>")
-- Set the following keybinds only after LSP attachment
local on_attach = function(_, bufnr)
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
@ -28,10 +28,12 @@ local on_attach = function(_, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
require("aerial").on_attach(client, bufnr)
end
-- Initialize servers that don't need any extra config
local simple_servers = {"rust_analyzer"}
local simple_servers = {}
for _, lsp in pairs(simple_servers) do
require("lspconfig")[lsp].setup {
on_attach = on_attach,
@ -47,6 +49,7 @@ table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
require("lspconfig").sumneko_lua.setup {
on_attach = on_attach,
settings = {
Lua = {
runtime = {

View file

@ -1,98 +0,0 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
_G._packer = _G._packer or {}
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/lu/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/lu/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/lu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/lu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/lu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["nvim-lspconfig"] = {
config = { "\27LJ\2\n+\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\16plugins.lsp\frequire\0" },
loaded = true,
path = "/home/lu/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["packer.nvim"] = {
loaded = false,
needs_bufread = false,
path = "/home/lu/.local/share/nvim/site/pack/packer/opt/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
}
}
time([[Defining packer_plugins]], false)
-- Config for: nvim-lspconfig
time([[Config for nvim-lspconfig]], true)
try_loadstring("\27LJ\2\n+\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\16plugins.lsp\frequire\0", "config", "nvim-lspconfig")
time([[Config for nvim-lspconfig]], false)
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end