Commit b10c54d8 authored by Tim van Deurzen's avatar Tim van Deurzen

Updated keybindings and settings for Neovim.

parent d58a3608
local t = function(str) local lspkind = require("lspkind")
return vim.api.nvim_replace_termcodes(str, true, true, true) lspkind.init()
end
local check_back_space = function() local has_words_before = function()
local col = vim.fn.col('.') - 1 local line, col = unpack(vim.api.nvim_win_get_cursor(0))
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
return true
else
return false
end
end end
-- Use (s-)tab to: local luasnip = require("luasnip")
--- move to prev/next item in completion menuone local cmp_autopairs = require("nvim-autopairs.completion.cmp")
--- jump to prev/next snippet's placeholder
_G.tab_complete = function() local cmp = require("cmp")
if vim.fn.pumvisible() == 1 then cmp.setup({
return t "<C-n>" completion = {
elseif vim.fn.call("vsnip#available", {1}) == 1 then completeopt = "menu,menuone,noinsert",
return t "<Plug>(vsnip-expand-or-jump)" },
elseif check_back_space() then
return t "<Tab>" mapping = {
else ["<C-d>"] = cmp.mapping.scroll_docs(-4),
return vim.fn['compe#complete']() ["<C-f>"] = cmp.mapping.scroll_docs(2),
end ["<C-e>"] = cmp.mapping.close(),
end ["<c-y>"] = cmp.mapping.confirm({
_G.s_tab_complete = function() behavior = cmp.ConfirmBehavior.Insert,
if vim.fn.pumvisible() == 1 then select = true,
return t "<C-p>" }),
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then ["<c-q>"] = cmp.mapping.confirm({
return t "<Plug>(vsnip-jump-prev)" behavior = cmp.ConfirmBehavior.Replace,
else select = true,
return t "<S-Tab>" }),
end
end ["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
-- Youtube:
-- the order of your sources matter (by default). That gives them priority
-- you can configure:
-- keyword_length
-- priority
-- max_item_count
-- (more?)
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer", keyword_length = 5 },
},
sorting = {
-- TODO: Would be cool to add stuff like "See variable names before method names" in rust, or something like that.
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
-- Youtube: How to set up nice formatting for your sources.
format = lspkind.cmp_format({
with_text = true,
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
gh_issues = "[issues]",
},
}),
},
experimental = {
-- I like the new menu better! Nice work hrsh7th
native_menu = false,
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) -- Let's play with this for a day or two
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) ghost_text = true,
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) },
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) })
local opts = {noremap = true, silent = true, expr = true} cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
vim.api.nvim_set_keymap("i", "<CR>", [[compe#confirm({'keys': "\<Plug>delimitMateCR", 'mode': ''})]], opts)
vim.api.nvim_set_keymap("i", "<c-c>", [[compe#complete()]], opts)
vim.api.nvim_set_keymap("i", "<c-e>", [[compe#close('<c-e>')]], opts)
This diff is collapsed.
return require('packer').startup(function() return require("packer").startup(function()
use 'wbthomason/packer.nvim' use("wbthomason/packer.nvim")
-- Color schemes -- Color schemes
use 'morhetz/gruvbox' use("morhetz/gruvbox")
use 'icymind/NeoSolarized' use("icymind/NeoSolarized")
use 'romgrk/doom-one.vim' use("romgrk/doom-one.vim")
use { use({
'tjdevries/gruvbuddy.nvim', "tjdevries/gruvbuddy.nvim",
requires = {'tjdevries/colorbuddy.vim'}, requires = { "tjdevries/colorbuddy.vim" },
config = function() config = function()
--require('colorbuddy').colorscheme('gruvbox') --require('colorbuddy').colorscheme('gruvbox')
vim.cmd[[colo gruvbox]] vim.cmd([[colo gruvbox]])
end end,
} })
-- UI -- UI
use 'ntpeters/vim-better-whitespace' use("ntpeters/vim-better-whitespace")
use 'Yggdroot/indentLine' use("Yggdroot/indentLine")
use 'haya14busa/incsearch.vim' use("haya14busa/incsearch.vim")
use { use({
'junegunn/fzf.vim', "junegunn/fzf.vim",
requires = {'junegunn/fzf'} requires = { "junegunn/fzf" },
} })
-- Look at feline for a leaner better maintained alternative. -- Look at feline for a leaner better maintained alternative.
use { use({
'glepnir/galaxyline.nvim', "glepnir/galaxyline.nvim",
branch = 'main', branch = "main",
config = function() config = function()
require('statusline') require("statusline")
end, end,
requires = {'kyazdani42/nvim-web-devicons'} requires = { "kyazdani42/nvim-web-devicons" },
} })
use 'liuchengxu/vista.vim' use("liuchengxu/vista.vim")
use 'kyazdani42/nvim-tree.lua' use({
use { "kyazdani42/nvim-tree.lua",
'AckslD/nvim-whichkey-setup.lua', requires = "kyazdani42/nvim-web-devicons",
requires = {'liuchengxu/vim-which-key'} config = function()
} require("nvim-tree").setup({})
use { end,
'akinsho/nvim-bufferline.lua', })
use({
requires = 'kyazdani42/nvim-web-devicons', "AckslD/nvim-whichkey-setup.lua",
requires = { "liuchengxu/vim-which-key" },
config = function() })
require('bufferline').setup{} use({
end "akinsho/nvim-bufferline.lua",
}
requires = "kyazdani42/nvim-web-devicons",
-- Utilities
use 'editorconfig/editorconfig-vim' config = function()
use { require("bufferline").setup({})
'nvim-treesitter/nvim-treesitter', end,
})
run = ':TSUpdate',
-- Utilities
requires = { use("editorconfig/editorconfig-vim")
'nvim-treesitter/nvim-treesitter-refactor', use({
'nvim-treesitter/nvim-treesitter-textobjects' "nvim-treesitter/nvim-treesitter",
},
} run = ":TSUpdate",
use {
'nvim-telescope/telescope.nvim', requires = {
"nvim-treesitter/nvim-treesitter-refactor",
requires = { "nvim-treesitter/nvim-treesitter-textobjects",
{'nvim-lua/popup.nvim'}, },
{'nvim-lua/plenary.nvim'}, })
{'nvim-telescope/telescope-project.nvim'} use({
}, "nvim-telescope/telescope.nvim",
config = function() requires = {
require('telescope').load_extension('project') { "nvim-lua/popup.nvim" },
end { "nvim-lua/plenary.nvim" },
} { "nvim-telescope/telescope-project.nvim" },
use 'Chiel92/vim-autoformat' },
use 'Raimondi/delimitMate'
use { config = function()
'Shougo/echodoc.vim', require("telescope").load_extension("project")
end,
config = function() })
vim.cmd [[let g:echodoc#enable_at_start=1]] use("Chiel92/vim-autoformat")
end use("Raimondi/delimitMate")
} use({
"Shougo/echodoc.vim",
-- Completion
use { config = function()
'hrsh7th/nvim-compe', vim.cmd([[let g:echodoc#enable_at_start=1]])
end,
config = function() })
require('compe').setup {
enabled = true; -- LSP
autocomplete = true; use("neovim/nvim-lspconfig")
debug = false; use({
min_length = 1; "RishabhRD/nvim-lsputils",
preselect = 'enable';
throttle_time = 80; requires = { "RishabhRD/popfix" },
source_timeout = 200; disable = true,
incomplete_delay = 400; })
max_abbr_width = 100;
max_kind_width = 100; use({
max_menu_width = 100; "nvim-lua/lsp_extensions.nvim",
documentation = true;
requires = { "neovim/nvim-lspconfig" },
source = {
path = true; disable = true,
buffer = true;
calc = true; config = function()
nvim_lsp = true; require("lsp_extensions").inlay_hints({
nvim_lua = true; highlight = "Comment",
vsnip = true; prefix = " » ",
}; aligned = true,
} only_current_line = false,
end, enabled = { "ChainingHint" },
})
requires = { end,
{ })
'hrsh7th/vim-vsnip',
use({
requires = {'hrsh7th/vim-vsnip-integ'} "folke/lsp-trouble.nvim",
} requires = "kyazdani42/nvim-web-devicons",
} config = function()
} require("trouble").setup({
-- your configuration comes here
-- LSP -- or leave it empty to use the default settings
use 'neovim/nvim-lspconfig' -- refer to the configuration section below
use { })
'RishabhRD/nvim-lsputils', end,
})
requires = {'RishabhRD/popfix'},
disable = true -- Completion
} use("onsails/lspkind-nvim")
use { use("hrsh7th/cmp-buffer")
'glepnir/lspsaga.nvim', use("hrsh7th/cmp-path")
use("hrsh7th/cmp-nvim-lua")
requires = {'neovim/nvim-lspconfig'}, use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/nvim-cmp")
config = function() use({
require('lspsaga').init_lsp_saga { "saadparwaiz1/cmp_luasnip",
error_sign = '•',
warn_sign = '•', requires = {
hint_sign = '•', "L3MON4D3/LuaSnip",
infor_sign = '•', },
code_action_icon = '?', })
border_style = 2,
code_action_prompt = { -- use "hrsh7th/cmp-vsnip"
enable = true, -- use "hrsh7th/vim-vsnip"
sign = true,
sign_priority = 20, use("windwp/nvim-autopairs")
virtual_text = false,
}, use({
code_action_keys = { "simrat39/rust-tools.nvim",
quit = '<esc>',
exec = '<CR>' requires = {
}, "nvim-lua/popup.nvim",
finder_action_keys = { },
open = 'o', })
vsplit = 's',
split = 'i', use({
quit = '<esc>', "lewis6991/gitsigns.nvim",
scroll_down = '<C-n>', requires = {
scroll_up = '<C-p>' "nvim-lua/plenary.nvim",
}, },
} config = function()
require("gitsigns").setup()
-- vim.api.nvim_command [[autocmd CursorHold,CursorHoldI * :lua require('lspsaga.signaturehelp').signature_help()]] end,
end })
}
use { use("tomlion/vim-solidity")
'nvim-lua/lsp_extensions.nvim',
requires = {'neovim/nvim-lspconfig'},
disable = true,
config = function()
require('lsp_extensions').inlay_hints{
highlight = "Comment",
prefix = " » ",
aligned = true,
only_current_line = false,
enabled = { "ChainingHint" }
}
end
}
use {
"folke/lsp-trouble.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end
}
use {
"ray-x/lsp_signature.nvim",
-- config = function()
-- end
}
use {
'simrat39/rust-tools.nvim',
requires = {
'nvim-lua/popup.nvim'
}
}
use {
'lewis6991/gitsigns.nvim',
requires = {
'nvim-lua/plenary.nvim'
},
config = function()
require('gitsigns').setup()
end
}
use 'tomlion/vim-solidity'
end) end)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment