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:
|
||||
-- status line
|
||||
-- goyo-like thing
|
||||
-- coq
|
||||
-- chadtree colors
|
||||
-- map A-S to toggle spell check (see logic from hlsearch section in init.vim)
|
||||
-- Blake's neovim rc file
|
||||
|
||||
-- basic settings: ~/.config/nvim/lua/settings.lua
|
||||
require('settings')
|
||||
-- plugins and plugin settings: ~/.config/nvim/lua/plugins.lua
|
||||
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 = {}
|
||||
|
||||
-- lsp_signature
|
||||
M.signature = function()
|
||||
M.signature = function() ---- lsp_signature >>>
|
||||
cfg = {
|
||||
Gse_lspsaga = true
|
||||
}
|
||||
end
|
||||
-- <<<
|
||||
|
||||
-- lspinstall
|
||||
M.lspinstall = function()
|
||||
M.lspinstall = function() ---- lspinstall >>>
|
||||
local function setup_servers()
|
||||
require'lspinstall'.setup()
|
||||
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
|
||||
end
|
||||
end
|
||||
-- <<<
|
||||
|
||||
-- treesitter
|
||||
M.treesitter = function ()
|
||||
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
|
||||
M.treesitter = function () ---- treesitter >>>
|
||||
require('nvim-treesitter.configs').setup {
|
||||
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,
|
||||
enable = true, -- false will disable the whole extension
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = 'gnn',
|
||||
node_incremental = 'grn',
|
||||
scope_incremental = 'grc',
|
||||
node_decremental = 'grm',
|
||||
},
|
||||
},
|
||||
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
|
||||
-- <<<
|
||||
|
||||
-- lspkind
|
||||
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()
|
||||
M.lspconfig = function() ---- lspconfig >>>
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- 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
|
||||
-- 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
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
|
@ -143,8 +217,9 @@ M.lspconfig = function()
|
|||
}
|
||||
end
|
||||
end
|
||||
-- <<<
|
||||
|
||||
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()
|
||||
-- Packer
|
||||
use { -- plugins
|
||||
use { -- plugins
|
||||
'wbthomason/packer.nvim'
|
||||
}
|
||||
|
||||
-- Colors
|
||||
use { -- syntax highlighting
|
||||
use { -- syntax highlighting
|
||||
'nvim-treesitter/nvim-treesitter', run = ':TSUpdate',
|
||||
config = function()
|
||||
require("lsp").treesitter()
|
||||
end,
|
||||
}
|
||||
use { -- onedark theme
|
||||
use { -- onedark theme
|
||||
'navarasu/onedark.nvim',
|
||||
config = function()
|
||||
-- vim.g.onedark_transparent_background = true,
|
||||
require('onedark').setup()
|
||||
end
|
||||
}
|
||||
use { -- color tag highlighter
|
||||
use { -- color tag highlighter
|
||||
'norcalli/nvim-colorizer.lua'
|
||||
}
|
||||
|
||||
-- IDE features
|
||||
---- LSP
|
||||
use { -- lsp installer
|
||||
use { -- lsp installer
|
||||
"kabouzeid/nvim-lspinstall",
|
||||
-- opt = true,
|
||||
-- setup = function()
|
||||
|
@ -44,21 +44,36 @@ return require('packer').startup(function()
|
|||
-- end, 0)
|
||||
-- end,
|
||||
}
|
||||
use { -- Default LSP configs
|
||||
use { -- Default LSP configs
|
||||
"neovim/nvim-lspconfig",
|
||||
after = "nvim-lspinstall",
|
||||
config = function()
|
||||
require("lsp").lspconfig()
|
||||
end
|
||||
}
|
||||
use { -- compe
|
||||
use { -- Icons for each entry in the completion menu
|
||||
"onsails/lspkind-nvim",
|
||||
}
|
||||
use { -- compe
|
||||
"hrsh7th/nvim-cmp",
|
||||
requires = {
|
||||
config = function()
|
||||
require('lsp').cmp()
|
||||
end,
|
||||
requires = { -- nvim-cmp sources
|
||||
"hrsh7th/vim-vsnip",
|
||||
"rafamadriz/friendly-snippets",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"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",
|
||||
after = "nvim-lspconfig",
|
||||
config = function()
|
||||
|
@ -71,12 +86,13 @@ return require('packer').startup(function()
|
|||
-- require("other").packer_lazy_load "vim-matchup"
|
||||
-- end,
|
||||
}
|
||||
-- use { -- ALE: Support for lots of linters, etc
|
||||
-- 'dense-analysis/ale',
|
||||
-- config = function()
|
||||
-- vim.g.ale_disable_lsp = 1
|
||||
-- end
|
||||
-- }
|
||||
use { -- ALE: Support for lots of linters, etc
|
||||
'dense-analysis/ale',
|
||||
ft = {'sh', 'zsh', 'bash', 'c', 'cc', 'cpp', 'cmake', 'html', 'markdown', 'racket', 'vim', 'tex'},
|
||||
config = function()
|
||||
vim.g.ale_disable_lsp = 1
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
---- Other IDE features
|
||||
|
@ -135,23 +151,20 @@ return require('packer').startup(function()
|
|||
use { -- Alignment
|
||||
'junegunn/vim-easy-align',
|
||||
}
|
||||
use { -- Quote/parenthesis changing
|
||||
use { -- tpope: Quote/parenthesis changing
|
||||
'tpope/vim-surround'
|
||||
}
|
||||
-- use { -- Some sensible defaults
|
||||
-- 'tpope/vim-sensible'
|
||||
-- }
|
||||
use { -- Comments
|
||||
use { -- tpope: Comments
|
||||
'tpope/vim-commentary'
|
||||
}
|
||||
-- use { -- Comments (lua)
|
||||
-- use { -- Comments (lua)
|
||||
-- "terrortylor/nvim-comment",
|
||||
-- require('conveniences').nvim_comment()
|
||||
-- }
|
||||
use { -- git integration
|
||||
use { -- tpope: git integration
|
||||
'tpope/vim-fugitive'
|
||||
}
|
||||
use { -- Repeatability for various tpope plugins
|
||||
use { -- tpope: Repeatability for various tpope plugins
|
||||
'tpope/vim-repeat',
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ set updatetime=300
|
|||
" Don't pass messages to |ins-completion-menu|.
|
||||
set shortmess+=c
|
||||
" Spell check!
|
||||
set spell spelllang=en_us
|
||||
set spelllang=en_us
|
||||
" spell check in git commits
|
||||
autocmd Filetype gitcommit setlocal spell
|
||||
set showcmd
|
||||
|
@ -71,7 +71,8 @@ command! WQ wq
|
|||
" nnoremap ; :
|
||||
" vnoremap ; :
|
||||
" 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
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
" Replace with alt S
|
||||
|
|
Loading…
Add table
Reference in a new issue