Major refactor of code completion, now very much nicer
This commit is contained in:
parent
56f3b08936
commit
dfd2dda8d0
12
init.lua
12
init.lua
|
@ -21,7 +21,7 @@ vim.opt.guifont = "DroidSansMono Nerd Font 11"
|
||||||
-- set colorscheme
|
-- set colorscheme
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
colorscheme slate
|
colorscheme tokyonight-night
|
||||||
]])
|
]])
|
||||||
|
|
||||||
-- vim.cmd('source ~/.config/nvim/viml/plugins.vim')
|
-- vim.cmd('source ~/.config/nvim/viml/plugins.vim')
|
||||||
|
@ -162,15 +162,6 @@ require("mason-lspconfig").setup_handlers({
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local wilder = require("wilder")
|
|
||||||
wilder.setup({
|
|
||||||
modes = { ":", "/", "?" },
|
|
||||||
next_key = "<Tab>",
|
|
||||||
previous_key = "<S-Tab>",
|
|
||||||
accept_key = "<c-k>",
|
|
||||||
reject_key = "<Up>",
|
|
||||||
})
|
|
||||||
|
|
||||||
require("code-completion")
|
require("code-completion")
|
||||||
|
|
||||||
-- neovide configuration
|
-- neovide configuration
|
||||||
|
@ -180,4 +171,3 @@ if vim.g.neovide then
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd("source ~/.config/nvim/viml/legacyconf.vim")
|
vim.cmd("source ~/.config/nvim/viml/legacyconf.vim")
|
||||||
vim.cmd("source ~/.config/nvim/viml/macros.vim")
|
|
||||||
|
|
|
@ -2,93 +2,101 @@
|
||||||
-- noinsert: only insert text when selection confirmed
|
-- noinsert: only insert text when selection confirmed
|
||||||
-- noselect: force to select from suggestion
|
-- noselect: force to select from suggestion
|
||||||
-- preview: show more details
|
-- preview: show more details
|
||||||
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert', 'preview'}
|
vim.opt.completeopt = { "menu", "menuone" }
|
||||||
|
|
||||||
-- shortmess is used to reduce verbocity
|
-- shortmess is used to reduce verbocity
|
||||||
-- vim.opt.shortmess = vim.opt.shortmess + { c = true }
|
-- vim.opt.shortmess = vim.opt.shortmess + { c = true }
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup({
|
||||||
|
-- configuration
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["UltiSnips#Anon"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
local cmp = require'cmp'
|
-- Add borders to the windows
|
||||||
cmp.setup( {
|
window = {
|
||||||
-- configuration
|
completion = cmp.config.window.bordered(),
|
||||||
snippet = {
|
documentation = cmp.config.window.bordered(),
|
||||||
expand = function(args)
|
},
|
||||||
vim.fn["UltiSnips#Anon"](args.body)
|
|
||||||
end,
|
-- mapping
|
||||||
},
|
mapping = cmp.mapping.preset.insert({
|
||||||
-- mapping
|
-- Shift+TAB to go to the Previous Suggested item
|
||||||
mapping = {
|
["<C-s-k>"] = cmp.mapping.select_prev_item(),
|
||||||
-- Shift+TAB to go to the Previous Suggested item
|
-- Tab to go to the next suggestion
|
||||||
['<C-s-k>'] = cmp.mapping.select_prev_item(),
|
["<C-k>"] = cmp.mapping.select_next_item(),
|
||||||
-- Tab to go to the next suggestion
|
-- CTRL+SHIFT+f to scroll backwards in description
|
||||||
['<C-k>'] = cmp.mapping.select_next_item(),
|
["<C-S-f>"] = cmp.mapping.scroll_docs(-4),
|
||||||
-- CTRL+SHIFT+f to scroll backwards in description
|
-- CTRL+F to scroll forwards in the description
|
||||||
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
-- CTRL+F to scroll forwards in the description
|
-- CTRL+SPACE to bring up completion at current Cursor location
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
-- CTRL+SPACE to bring up completion at current Cursor location
|
-- CTRL+e to exit suggestion and close it
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
["<C-s-CR>"] = cmp.mapping.close(), -- TODO: Search better option
|
||||||
-- CTRL+e to exit suggestion and close it
|
-- CR (enter or return) to CONFIRM the currently selection suggestion
|
||||||
['<C-e>'] = cmp.mapping.close(),
|
-- We set the ConfirmBehavior to insert the Selected suggestion
|
||||||
-- CR (enter or return) to CONFIRM the currently selection suggestion
|
["<CR>"] = cmp.mapping.confirm({
|
||||||
-- We set the ConfirmBehavior to insert the Selected suggestion
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
['<CR>'] = cmp.mapping.confirm({
|
select = true,
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
}),
|
||||||
select = true,
|
}),
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
-- installed sources for code suggestion
|
-- installed sources for code suggestion
|
||||||
sources = {
|
sources = cmp.config.sources({
|
||||||
{ name = 'path' },
|
{ name = "path" },
|
||||||
{ name = 'nvim_lsp', keyword_length = 3 },
|
{ name = "nvim_lsp", keyword_length = 1 },
|
||||||
{ name = 'nvim_lsp_signature_help'},
|
{ name = "nvim_lsp_signature_help" },
|
||||||
{ name = 'nvim_lua', keyword_length = 2},
|
{ name = "nvim_lua", keyword_length = 2 },
|
||||||
{ name = 'buffer', keyword_length = 2 },
|
{ name = "buffer", keyword_length = 4 },
|
||||||
{ name = 'ultisnips', keyword_length = 2 },
|
{ name = "ultisnips", keyword_length = 1 },
|
||||||
{ name = 'calc' },
|
{ name = "calc" },
|
||||||
{ name = "lua-latex-symbols", option = { cache = true } }
|
{ name = "lua-latex-symbols", option = { cache = true } },
|
||||||
},
|
}),
|
||||||
|
|
||||||
-- Add borders to the windows
|
-- add formatting of the different sources
|
||||||
window = {
|
formatting = {
|
||||||
completion = cmp.config.window.bordered(),
|
fields = { "menu", "abbr", "kind" },
|
||||||
documentation = cmp.config.window.bordered(),
|
format = function(entry, item)
|
||||||
},
|
local menu_icon = {
|
||||||
-- add formating of the different sources
|
nvim_lsp = "λ",
|
||||||
formatting = {
|
ultisnips = "⋗",
|
||||||
fields = {'menu', 'abbr', 'kind'},
|
buffer = "b",
|
||||||
format = function(entry, item)
|
path = "p",
|
||||||
local menu_icon ={
|
calc = "Σ",
|
||||||
nvim_lsp = 'λ',
|
lualatexsymbols = "L",
|
||||||
ultisnips = '⋗',
|
}
|
||||||
buffer = 'b',
|
item.menu = menu_icon[entry.source.name]
|
||||||
path = 'p',
|
return item
|
||||||
calc = 'Σ',
|
end,
|
||||||
lualatexsymbols = 'L'
|
},
|
||||||
}
|
})
|
||||||
item.menu = menu_icon[entry.source.name]
|
|
||||||
return item
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
} )
|
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
cmp.setup.filetype('gitcommit', {
|
cmp.setup.filetype("gitcommit", {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
{ name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = "buffer" },
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline({ "/", "?" }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline(':', {
|
cmp.setup.cmdline(":", {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'path' }
|
{ name = "path" },
|
||||||
}, {
|
{ name = "cmdline_history", keyword_length = 15 },
|
||||||
{ name = 'cmdline' }
|
}, {
|
||||||
})
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
return require("packer").startup(function(use)
|
return require("packer").startup(function(use)
|
||||||
-- Configurations will go here soon
|
-- Configurations will go here soon
|
||||||
use("wbthomason/packer.nvim")
|
use("wbthomason/packer.nvim")
|
||||||
-- use 'dense-analysis/ale'
|
|
||||||
use("preservim/nerdtree")
|
use("preservim/nerdtree")
|
||||||
use("Xuyuanp/nerdtree-git-plugin")
|
use("Xuyuanp/nerdtree-git-plugin")
|
||||||
use("tpope/vim-surround")
|
use("tpope/vim-surround")
|
||||||
use("SirVer/ultisnips")
|
use("SirVer/ultisnips")
|
||||||
|
use("powerline/powerline")
|
||||||
use("vim-airline/vim-airline")
|
use("vim-airline/vim-airline")
|
||||||
|
use("vim-airline/vim-airline-themes")
|
||||||
use({
|
use({
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
run = function()
|
run = function()
|
||||||
|
@ -14,7 +15,6 @@ return require("packer").startup(function(use)
|
||||||
ts_update()
|
ts_update()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
use({ "gelguy/wilder.nvim" })
|
|
||||||
use({ "junegunn/fzf", run = ":call fzf#install()" })
|
use({ "junegunn/fzf", run = ":call fzf#install()" })
|
||||||
use("junegunn/fzf.vim")
|
use("junegunn/fzf.vim")
|
||||||
use("williamboman/mason.nvim")
|
use("williamboman/mason.nvim")
|
||||||
|
@ -33,6 +33,8 @@ return require("packer").startup(function(use)
|
||||||
use("hrsh7th/cmp-path")
|
use("hrsh7th/cmp-path")
|
||||||
use("hrsh7th/cmp-buffer")
|
use("hrsh7th/cmp-buffer")
|
||||||
use("hrsh7th/cmp-calc")
|
use("hrsh7th/cmp-calc")
|
||||||
|
use("hrsh7th/cmp-cmdline")
|
||||||
|
use("dmitmel/cmp-cmdline-history")
|
||||||
use("amarakon/nvim-cmp-lua-latex-symbols")
|
use("amarakon/nvim-cmp-lua-latex-symbols")
|
||||||
use("prabirshrestha/async.vim")
|
use("prabirshrestha/async.vim")
|
||||||
use("prabirshrestha/vim-lsp")
|
use("prabirshrestha/vim-lsp")
|
||||||
|
@ -43,5 +45,6 @@ return require("packer").startup(function(use)
|
||||||
use("quangnguyen30192/cmp-nvim-ultisnips")
|
use("quangnguyen30192/cmp-nvim-ultisnips")
|
||||||
use("ryanoasis/vim-devicons")
|
use("ryanoasis/vim-devicons")
|
||||||
use("mhartington/formatter.nvim")
|
use("mhartington/formatter.nvim")
|
||||||
use("tzachar/highlight-undo.nvim")
|
use("tzachar/highlight-undo.nvim")
|
||||||
|
use("folke/tokyonight.nvim")
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -38,7 +38,7 @@ nnoremap <C-g> :call Litde()<CR>
|
||||||
|
|
||||||
" Theme
|
" Theme
|
||||||
nnoremap <M-+> :colo morning<CR>
|
nnoremap <M-+> :colo morning<CR>
|
||||||
nnoremap <M--> :colo slate<CR>
|
nnoremap <M--> :colo tokyonight-night<CR>
|
||||||
|
|
||||||
" Fuzzy finder
|
" Fuzzy finder
|
||||||
nnoremap <C-f> :Lines<CR>
|
nnoremap <C-f> :Lines<CR>
|
||||||
|
|
Loading…
Reference in New Issue