Major neovim updates (mostly completion-related)
This commit is contained in:
parent
b01adf63d1
commit
8f9fcd34e2
4 changed files with 211 additions and 101 deletions
|
@ -1,12 +1,33 @@
|
||||||
-- TODO:
|
-- Blake's neovim rc file
|
||||||
-- status line
|
|
||||||
-- goyo-like thing
|
|
||||||
-- coq
|
|
||||||
-- chadtree colors
|
|
||||||
-- map A-S to toggle spell check (see logic from hlsearch section in init.vim)
|
|
||||||
|
|
||||||
-- basic settings: ~/.config/nvim/lua/settings.lua
|
-- basic settings: ~/.config/nvim/lua/settings.lua
|
||||||
require('settings')
|
require('settings')
|
||||||
-- plugins and plugin settings: ~/.config/nvim/lua/plugins.lua
|
-- plugins and plugin settings: ~/.config/nvim/lua/plugins.lua
|
||||||
require('plugins')
|
require('plugins')
|
||||||
|
|
||||||
|
-- TODO:
|
||||||
|
--
|
||||||
|
-- Misc:
|
||||||
|
-- [X] map A-S to toggle spell check (see logic from hlsearch section in init.vim)
|
||||||
|
--
|
||||||
|
-- Plugins to Configure
|
||||||
|
-- [ ] toggleterm
|
||||||
|
-- [ ] neoscroll
|
||||||
|
--
|
||||||
|
-- Plugins to install:
|
||||||
|
-- [ ] telescope
|
||||||
|
-- [ ] zen-mode.nvim (goyo)
|
||||||
|
-- [ ] status line
|
||||||
|
-- [ ] chadtree keymap
|
||||||
|
-- [ ] lspsaga
|
||||||
|
-- [ ] lightspeed.nvim or hop.nvim
|
||||||
|
-- [ ] lightbulb
|
||||||
|
-- [ ] glow.nvim (markdown preview)
|
||||||
|
-- [ ] auto-session
|
||||||
|
-- [ ] shade.nvim
|
||||||
|
-- [ ] presence.nvim (discord presence)
|
||||||
|
-- [ ] trouble.nvim
|
||||||
|
-- [ ] indent-blankline.nvim (line indent level indicator)
|
||||||
|
-- [ ] commented.nvim ?
|
||||||
|
-- [ ] symbols-outline.nvim ?
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- lsp_signature
|
M.signature = function() ---- lsp_signature >>>
|
||||||
M.signature = function()
|
|
||||||
cfg = {
|
cfg = {
|
||||||
Gse_lspsaga = true
|
Gse_lspsaga = true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
-- <<<
|
||||||
|
|
||||||
-- lspinstall
|
M.lspinstall = function() ---- lspinstall >>>
|
||||||
M.lspinstall = function()
|
|
||||||
local function setup_servers()
|
local function setup_servers()
|
||||||
require'lspinstall'.setup()
|
require'lspinstall'.setup()
|
||||||
local servers = require'lspinstall'.installed_servers()
|
local servers = require'lspinstall'.installed_servers()
|
||||||
|
@ -25,77 +24,152 @@ M.lspinstall = function()
|
||||||
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
|
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- <<<
|
||||||
|
|
||||||
-- treesitter
|
M.treesitter = function () ---- treesitter >>>
|
||||||
M.treesitter = function ()
|
require('nvim-treesitter.configs').setup {
|
||||||
require'nvim-treesitter.configs'.setup {
|
|
||||||
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
|
||||||
--ignore_install = { "javascript", "java" }, -- List of parsers to ignore installing
|
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true, -- false will disable the whole extension
|
enable = true, -- false will disable the whole extension
|
||||||
-- disable = { "c", "rust" }, -- list of language that will be disabled
|
},
|
||||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
incremental_selection = {
|
||||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
enable = true,
|
||||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
keymaps = {
|
||||||
-- Instead of true it can also be a list of languages
|
init_selection = 'gnn',
|
||||||
additional_vim_regex_highlighting = false,
|
node_incremental = 'grn',
|
||||||
|
scope_incremental = 'grc',
|
||||||
|
node_decremental = 'grm',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
indent = {
|
indent = {
|
||||||
enable = true
|
enable = true,
|
||||||
}
|
},
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||||
|
keymaps = {
|
||||||
|
-- You can use the capture groups defined in textobjects.scm
|
||||||
|
['af'] = '@function.outer',
|
||||||
|
['if'] = '@function.inner',
|
||||||
|
['ac'] = '@class.outer',
|
||||||
|
['ic'] = '@class.inner',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
move = {
|
||||||
|
enable = true,
|
||||||
|
set_jumps = true, -- whether to set jumps in the jumplist
|
||||||
|
goto_next_start = {
|
||||||
|
[']m'] = '@function.outer',
|
||||||
|
[']]'] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_next_end = {
|
||||||
|
[']M'] = '@function.outer',
|
||||||
|
[']['] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_previous_start = {
|
||||||
|
['[m'] = '@function.outer',
|
||||||
|
['[['] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_previous_end = {
|
||||||
|
['[M'] = '@function.outer',
|
||||||
|
['[]'] = '@class.outer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- require'nvim-treesitter.configs'.setup {
|
||||||
|
-- ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||||
|
-- --ignore_install = { "javascript", "java" }, -- List of parsers to ignore installing
|
||||||
|
-- highlight = {
|
||||||
|
-- enable = true, -- false will disable the whole extension
|
||||||
|
-- -- disable = { "c", "rust" }, -- list of language that will be disabled
|
||||||
|
-- -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||||
|
-- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||||
|
-- -- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||||
|
-- -- Instead of true it can also be a list of languages
|
||||||
|
-- additional_vim_regex_highlighting = false,
|
||||||
|
-- },
|
||||||
|
-- indent = {
|
||||||
|
-- enable = true
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
end
|
||||||
|
-- <<<
|
||||||
|
|
||||||
|
M.cmp = function() ---- cmp >>>
|
||||||
|
-- nvim-cmp supports additional completion capabilities
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||||
|
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["vsnip#anonymous"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<Tab>'] = function(fallback)
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = function(fallback)
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
{ name = 'calc' },
|
||||||
|
{ name = 'vsnip' },
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'spell' },
|
||||||
|
{ name = 'treesitter' },
|
||||||
|
{ name = 'emoji' },
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
-- fancy icons and a name of kind
|
||||||
|
vim_item.kind = require("lspkind").presets.default[vim_item.kind] .. " " .. vim_item.kind
|
||||||
|
|
||||||
|
-- set a name for each source
|
||||||
|
vim_item.menu = ({
|
||||||
|
buffer = "[Buffer]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
luasnip = "[LuaSnip]",
|
||||||
|
nvim_lua = "[Lua]",
|
||||||
|
latex_symbols = "[Latex]",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
-- <<<
|
||||||
|
|
||||||
-- lspkind
|
M.lspconfig = function() ---- lspconfig >>>
|
||||||
M.lspkind = function()
|
|
||||||
require('lspkind').init({
|
|
||||||
-- enables text annotations
|
|
||||||
--
|
|
||||||
-- default: true
|
|
||||||
with_text = true,
|
|
||||||
|
|
||||||
-- default symbol map
|
|
||||||
-- can be either 'default' (requires nerd-fonts font) or
|
|
||||||
-- 'codicons' for codicon preset (requires vscode-codicons font)
|
|
||||||
--
|
|
||||||
-- default: 'default'
|
|
||||||
preset = 'codicons',
|
|
||||||
|
|
||||||
-- override preset symbols
|
|
||||||
--
|
|
||||||
-- default: {}
|
|
||||||
symbol_map = {
|
|
||||||
Text = "",
|
|
||||||
Method = "",
|
|
||||||
Function = "",
|
|
||||||
Constructor = "",
|
|
||||||
Field = "ﰠ",
|
|
||||||
Variable = "",
|
|
||||||
Class = "ﴯ",
|
|
||||||
Interface = "",
|
|
||||||
Module = "",
|
|
||||||
Property = "ﰠ",
|
|
||||||
Unit = "塞",
|
|
||||||
Value = "",
|
|
||||||
Enum = "",
|
|
||||||
Keyword = "",
|
|
||||||
Snippet = "",
|
|
||||||
Color = "",
|
|
||||||
File = "",
|
|
||||||
Reference = "",
|
|
||||||
Folder = "",
|
|
||||||
EnumMember = "",
|
|
||||||
Constant = "",
|
|
||||||
Struct = "פּ",
|
|
||||||
Event = "",
|
|
||||||
Operator = "",
|
|
||||||
TypeParameter = ""
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- lspconfig
|
|
||||||
M.lspconfig = function()
|
|
||||||
local nvim_lsp = require('lspconfig')
|
local nvim_lsp = require('lspconfig')
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
|
@ -133,7 +207,7 @@ M.lspconfig = function()
|
||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
-- map buffer local keybindings when the language server attaches
|
-- map buffer local keybindings when the language server attaches
|
||||||
local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
|
local servers = { 'clangd', 'bash' }
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvim_lsp[lsp].setup {
|
nvim_lsp[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
@ -143,8 +217,9 @@ M.lspconfig = function()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- <<<
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
-- vim:expandtab:tabstop=3:sw=3
|
-- vim:fdm=marker:fmr=>>>,<<<:expandtab:tabstop=3:sw=3
|
||||||
|
|
||||||
|
|
|
@ -9,31 +9,31 @@ end
|
||||||
|
|
||||||
return require('packer').startup(function()
|
return require('packer').startup(function()
|
||||||
-- Packer
|
-- Packer
|
||||||
use { -- plugins
|
use { -- plugins
|
||||||
'wbthomason/packer.nvim'
|
'wbthomason/packer.nvim'
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Colors
|
-- Colors
|
||||||
use { -- syntax highlighting
|
use { -- syntax highlighting
|
||||||
'nvim-treesitter/nvim-treesitter', run = ':TSUpdate',
|
'nvim-treesitter/nvim-treesitter', run = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
require("lsp").treesitter()
|
require("lsp").treesitter()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
use { -- onedark theme
|
use { -- onedark theme
|
||||||
'navarasu/onedark.nvim',
|
'navarasu/onedark.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
-- vim.g.onedark_transparent_background = true,
|
-- vim.g.onedark_transparent_background = true,
|
||||||
require('onedark').setup()
|
require('onedark').setup()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
use { -- color tag highlighter
|
use { -- color tag highlighter
|
||||||
'norcalli/nvim-colorizer.lua'
|
'norcalli/nvim-colorizer.lua'
|
||||||
}
|
}
|
||||||
|
|
||||||
-- IDE features
|
-- IDE features
|
||||||
---- LSP
|
---- LSP
|
||||||
use { -- lsp installer
|
use { -- lsp installer
|
||||||
"kabouzeid/nvim-lspinstall",
|
"kabouzeid/nvim-lspinstall",
|
||||||
-- opt = true,
|
-- opt = true,
|
||||||
-- setup = function()
|
-- setup = function()
|
||||||
|
@ -44,21 +44,36 @@ return require('packer').startup(function()
|
||||||
-- end, 0)
|
-- end, 0)
|
||||||
-- end,
|
-- end,
|
||||||
}
|
}
|
||||||
use { -- Default LSP configs
|
use { -- Default LSP configs
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
after = "nvim-lspinstall",
|
after = "nvim-lspinstall",
|
||||||
config = function()
|
config = function()
|
||||||
require("lsp").lspconfig()
|
require("lsp").lspconfig()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
use { -- compe
|
use { -- Icons for each entry in the completion menu
|
||||||
|
"onsails/lspkind-nvim",
|
||||||
|
}
|
||||||
|
use { -- compe
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
requires = {
|
config = function()
|
||||||
|
require('lsp').cmp()
|
||||||
|
end,
|
||||||
|
requires = { -- nvim-cmp sources
|
||||||
"hrsh7th/vim-vsnip",
|
"hrsh7th/vim-vsnip",
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-nvim-lua",
|
||||||
|
"hrsh7th/cmp-latex-symbols",
|
||||||
|
"hrsh7th/cmp-vsnip",
|
||||||
|
"hrsh7th/cmp-emoji",
|
||||||
|
"hrsh7th/cmp-calc",
|
||||||
|
"hrsh7th/cmp-look",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use { -- function parameter previews
|
use { -- function parameter previews
|
||||||
"ray-x/lsp_signature.nvim",
|
"ray-x/lsp_signature.nvim",
|
||||||
after = "nvim-lspconfig",
|
after = "nvim-lspconfig",
|
||||||
config = function()
|
config = function()
|
||||||
|
@ -71,12 +86,13 @@ return require('packer').startup(function()
|
||||||
-- require("other").packer_lazy_load "vim-matchup"
|
-- require("other").packer_lazy_load "vim-matchup"
|
||||||
-- end,
|
-- end,
|
||||||
}
|
}
|
||||||
-- use { -- ALE: Support for lots of linters, etc
|
use { -- ALE: Support for lots of linters, etc
|
||||||
-- 'dense-analysis/ale',
|
'dense-analysis/ale',
|
||||||
-- config = function()
|
ft = {'sh', 'zsh', 'bash', 'c', 'cc', 'cpp', 'cmake', 'html', 'markdown', 'racket', 'vim', 'tex'},
|
||||||
-- vim.g.ale_disable_lsp = 1
|
config = function()
|
||||||
-- end
|
vim.g.ale_disable_lsp = 1
|
||||||
-- }
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
---- Other IDE features
|
---- Other IDE features
|
||||||
|
@ -135,23 +151,20 @@ return require('packer').startup(function()
|
||||||
use { -- Alignment
|
use { -- Alignment
|
||||||
'junegunn/vim-easy-align',
|
'junegunn/vim-easy-align',
|
||||||
}
|
}
|
||||||
use { -- Quote/parenthesis changing
|
use { -- tpope: Quote/parenthesis changing
|
||||||
'tpope/vim-surround'
|
'tpope/vim-surround'
|
||||||
}
|
}
|
||||||
-- use { -- Some sensible defaults
|
use { -- tpope: Comments
|
||||||
-- 'tpope/vim-sensible'
|
|
||||||
-- }
|
|
||||||
use { -- Comments
|
|
||||||
'tpope/vim-commentary'
|
'tpope/vim-commentary'
|
||||||
}
|
}
|
||||||
-- use { -- Comments (lua)
|
-- use { -- Comments (lua)
|
||||||
-- "terrortylor/nvim-comment",
|
-- "terrortylor/nvim-comment",
|
||||||
-- require('conveniences').nvim_comment()
|
-- require('conveniences').nvim_comment()
|
||||||
-- }
|
-- }
|
||||||
use { -- git integration
|
use { -- tpope: git integration
|
||||||
'tpope/vim-fugitive'
|
'tpope/vim-fugitive'
|
||||||
}
|
}
|
||||||
use { -- Repeatability for various tpope plugins
|
use { -- tpope: Repeatability for various tpope plugins
|
||||||
'tpope/vim-repeat',
|
'tpope/vim-repeat',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ set updatetime=300
|
||||||
" Don't pass messages to |ins-completion-menu|.
|
" Don't pass messages to |ins-completion-menu|.
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
" Spell check!
|
" Spell check!
|
||||||
set spell spelllang=en_us
|
set spelllang=en_us
|
||||||
" spell check in git commits
|
" spell check in git commits
|
||||||
autocmd Filetype gitcommit setlocal spell
|
autocmd Filetype gitcommit setlocal spell
|
||||||
set showcmd
|
set showcmd
|
||||||
|
@ -71,7 +71,8 @@ command! WQ wq
|
||||||
" nnoremap ; :
|
" nnoremap ; :
|
||||||
" vnoremap ; :
|
" vnoremap ; :
|
||||||
" Press Alt h to toggle highlighting on/off, and show current value.
|
" Press Alt h to toggle highlighting on/off, and show current value.
|
||||||
noremap <M-h> :set hlsearch! hlsearch?<CR>
|
noremap <M-h> <cmd>set hlsearch! hlsearch?<CR>
|
||||||
|
noremap <M-S> <cmd>set spell! spell?<CR>
|
||||||
" Escape to enter normal mode in the terminal
|
" Escape to enter normal mode in the terminal
|
||||||
tnoremap <Esc> <C-\><C-n>
|
tnoremap <Esc> <C-\><C-n>
|
||||||
" Replace with alt S
|
" Replace with alt S
|
||||||
|
|
Loading…
Add table
Reference in a new issue