Compare commits

..

2 commits

Author SHA1 Message Date
eba39d2334
nvim: Add minimap toggle mapping 2023-02-10 15:38:22 +01:00
2026f6d064
nvim: Switch to lsp-zero
lsp-zero offers a simple to set-up lsp configuration which is based
around the plugins I use anyway (lsp, cmp, luasnip) but integrates them
very well. I add a few small quality of life things on top (cmp
completion for / search and for vim command mode) as well as a boatload
of custom completion sources but otherwise make use of the nice presets.

This has de-bloated my _cmp.lua settings somewhat and allows me to have
a simple treesitter and a simple(r) lsp setup!

Additionally, switched to mason.nvim to manage my lsp sources (and
linters), which is both the new hotness and actually really useful.
Allows portable installation of most lsp servers into neovim data
directory so they do not clutter any other directories or global
namespaces.
2023-02-10 15:33:33 +01:00
4 changed files with 140 additions and 195 deletions

View file

@ -1,5 +1,6 @@
{
"BetterLua.vim": { "branch": "master", "commit": "d2d6c115575d09258a794a6f20ac60233eee59d5" },
"LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" },
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
"bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
@ -12,7 +13,7 @@
"cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" },
"cmp-tmux": { "branch": "main", "commit": "984772716f66d8ee88535a6bf3f94c4b4e1301f5" },
"cmp-treesitter": { "branch": "master", "commit": "b40178b780d547bcf131c684bc5fd41af17d05f2" },
"cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"completion-vcard": { "branch": "master", "commit": "2220fd517a985ececed1adcf0e5be8f2815564c7" },
"dial.nvim": { "branch": "master", "commit": "5020da900cc5dfd7067f181ee2ebd872ca7c84e8" },
"formatter.nvim": { "branch": "master", "commit": "8a4c961330cc4688087f23d18fa7d2f1af9a4902" },
@ -21,11 +22,14 @@
"guihua.lua": { "branch": "master", "commit": "d3f6d01639b52e6a83ea98dd6ca244c9aa98b79b" },
"lazy.nvim": { "branch": "main", "commit": "273081443471cbc52c327bcb99614c32f247998d" },
"lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" },
"lsp-format.nvim": { "branch": "master", "commit": "ca0df5c8544e51517209ea7b86ecc522c98d4f0a" },
"lsp-zero.nvim": { "branch": "main", "commit": "42bc5a1081666098a7154532e6ff5e3edc483b39" },
"lsp_signature.nvim": { "branch": "master", "commit": "6f6252f63b0baf0f2224c4caea33819a27f3f550" },
"lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" },
"lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" },
"magma-nvim-goose": { "branch": "main", "commit": "94370733757d550594fe4a1d65643949d7485989" },
"markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7a97a77eee486ae152d2c559a459eda7c8aa12aa" },
"mason.nvim": { "branch": "main", "commit": "14ae1ca58440b158a0a35cf90773013caddf788a" },
"mini.nvim": { "branch": "main", "commit": "dc0ccf1b0499d649a6177d2a406babcfe73b97de" },
"nabla.nvim": { "branch": "master", "commit": "ddbfc6e244e79db9280c535ee85c81388c5d1b46" },
"navigator.lua": { "branch": "master", "commit": "66d84151e94052f710b1dfb0d1fce2faaca6dced" },
@ -63,7 +67,6 @@
"vim-pandoc": { "branch": "master", "commit": "9f406d964ca70d959b7867f1b5cee3d4884d4d3c" },
"vim-pandoc-syntax": { "branch": "master", "commit": "4268535e1d33117a680a91160d845cd3833dfe28" },
"vim-spellsync": { "branch": "master", "commit": "27e103f2d283a1f6e24cc99dbdcd624713aff277" },
"vim-vsnip": { "branch": "master", "commit": "8dde8c0ef10bb1afdbb301e2bd7eb1c153dd558e" },
"which-key.nvim": { "branch": "main", "commit": "684e96c5e8477f1ee9b3f2e9a12d802fd12c5531" },
"zen-mode.nvim": { "branch": "main", "commit": "3c92f503823088862ca2a7809d1c7edc90fb92fa" },
"zettelkasten.nvim": { "branch": "main", "commit": "0e77624689b470410f5355b613d45219c9350264" }

View file

@ -192,6 +192,9 @@ map('n', '<localleader>ZG', ':setlocal spell! spelllang=de_de<cr>',
map('i', '<c-s>', '<C-G>u<Esc>[s1z=`]a<C-G>u')
map('n', '<localleader>s', 'ms[s1z=`s', { desc = 'Fix last spell error' })
-- PLUGIN: mini.nvim
map('n', '<leader>m', ':lua MiniMap.toggle()<cr>', { silent = true })
-- PLUGIN: easy-align
-- Start interactive EasyAlign in visual mode (e.g. vipga)
map('x', 'ga', '<Plug>(EasyAlign)')

View file

@ -1,95 +1,40 @@
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.on_attach(function(client, bufnr)
require("lsp-format").on_attach(client, bufnr)
end)
lsp.nvim_workspace()
lsp.setup_nvim_cmp({
sources = {
{ name = 'path' }, { name = 'nvim_lsp', keyword_length = 2 },
{ name = 'buffer', keyword_length = 3 },
{ name = 'luasnip', keyword_length = 2 }, { name = 'tmux' },
{ name = 'otter' }, { name = 'latex_symbols' }, { name = 'vCard' },
{ name = 'nvim_lua' }, { name = 'buffer' }, { name = 'spell' }
},
documentation = {
max_height = 50,
max_width = 90,
border = 'rounded',
col_offset = 0,
side_padding = 1,
winhighlight = 'Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None',
zindex = 1001
}
})
lsp.setup()
vim.diagnostic.config { virtual_text = true }
local cmp = require 'cmp'
local lspkind = require 'lspkind'
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
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
mode, true)
end
vim.o.completeopt = "menu,menuone,noselect"
-- completion items
require('cmp').register_source('vCard', require('completion_vcard').setup_cmp(
'~/documents/contacts/myconts'))
vim.g.vsnip_snippet_dir = (vim.env.XDG_DATA_HOME or "~/.local/share") ..
"/nvim/snippets"
cmp.setup({
snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end },
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()
}),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = false }),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" })
},
formatting = {
format = lspkind.cmp_format({
with_text = false,
menu = ({
buffer = "B",
nvim_lua = "NLua",
tmux = "τ",
vCard = "VCARD"
})
})
},
sources = cmp.config.sources({
{ name = 'path' }, { name = 'nvim_lsp' }, { name = 'treesitter' },
{ name = 'tmux' }, { name = 'vsnip' }, { name = 'otter' },
{ name = 'latex_symbols' }, { name = 'vCard' }, { name = 'nvim_lua' }
}, { { name = 'buffer' }, { name = 'spell' } })
})
if vim.o.ft == 'clap_input' and vim.o.ft == 'guihua' and vim.o.ft ==
'guihua_rust' then require 'cmp'.setup.buffer { completion = { enable = false } } end
-- set up pandoc bibtex source generation
require 'cmp_pandoc'.setup()
-- Use buffer source for `/` search
-- `/` cmdline setup.
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = 'buffer' } })
sources = { { name = 'buffer' } }
})
-- Use cmdline & path source for ':' in vim
-- `:` cmdline setup.
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } })
sources = cmp.config.sources({ { name = 'path' } }, {
{ name = 'cmdline', option = { ignore_cmds = { 'Man', '!' } } }
})
})
require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol
.make_client_capabilities())

View file

@ -108,8 +108,7 @@ return {
'echasnovski/mini.nvim',
version = '*',
config = function() require('plug._mini') end
},
{
}, {
"akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim
config = function() require('plug._toggleterm') end,
event = "BufWinEnter"
@ -129,10 +128,7 @@ return {
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" },
config = function() require('plug._telescope') end
}, -- snippeting
{"hrsh7th/vim-vsnip", event = "InsertEnter"}, -- snippet engine
{"rafamadriz/friendly-snippets", event = "InsertEnter"}, -- many snippets
-- treesitter
}, -- treesitter
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
@ -160,12 +156,25 @@ return {
config = function() require('spellsitter').setup() end,
event = "BufReadPre"
}, -- lsp
{'neovim/nvim-lspconfig', event = "VeryLazy"}, -- some common language server configurations
{
'simrat39/symbols-outline.nvim',
config = function() require('symbols-outline').setup() end,
event = "VeryLazy"
}, -- vista-like outline view for code
"VonHeikemen/lsp-zero.nvim",
dependencies = {
"neovim/nvim-lspconfig", "williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim", "hrsh7th/nvim-cmp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua", "L3MON4D3/LuaSnip",
"rafamadriz/friendly-snippets", "andersevenrud/cmp-tmux",
"hrsh7th/cmp-nvim-lsp", "kdheepak/cmp-latex-symbols",
"ray-x/cmp-treesitter", "f3fora/cmp-spell", "hrsh7th/cmp-cmdline",
"cbarrete/completion-vcard", {
'aspeddro/cmp-pandoc.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'jbyuki/nabla.nvim' },
event = "InsertEnter"
}, { "lukas-reineke/lsp-format.nvim", config = true }
},
config = function() require('plug._cmp') end
}, { 'simrat39/symbols-outline.nvim', config = true, event = "VeryLazy" }, -- vista-like outline view for code
{ 'ray-x/lsp_signature.nvim', event = "VeryLazy" },
{ 'ray-x/guihua.lua', build = 'cd lua/fzy && make', event = "VeryLazy" }, {
'ray-x/navigator.lua',
@ -173,29 +182,14 @@ return {
event = "VeryLazy"
}, -- and completion
{
'hrsh7th/nvim-cmp', -- simple completion engine built specifically for nvim and lsp
dependencies = {
'onsails/lspkind-nvim', 'andersevenrud/cmp-tmux', -- completion source from adjacent tmux panes
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-nvim-lua',
'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter',
'f3fora/cmp-spell', 'cbarrete/completion-vcard'
},
event = "VeryLazy",
config = function() require('plug._cmp') end
}, {
'aspeddro/cmp-pandoc.nvim',
dependencies = {'nvim-lua/plenary.nvim', 'jbyuki/nabla.nvim'},
event = "VeryLazy"
}, {
"jghauser/papis.nvim",
after = { "telescope.nvim", "nvim-cmp" },
dependencies = {
"kkharji/sqlite.lua", "nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter"
},
event = "VeryLazy",
ft = writing_ft,
rocks = { "lyaml" },
config = function() require("papis").setup({}) end
config = true
}
}