Commit 7a218dbc authored by Tim van Deurzen's avatar Tim van Deurzen

Update plugins, keybindings and settings extensively.

parent f633aca1
-- Load all the configuration modules
require("core")
require("keybindings")
require("plugins")
require("lsp")
require("keybindings")
require("treesitter")
......@@ -15,20 +15,24 @@ end
--- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder
_G.tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-n>"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
if vim.fn.pumvisible() == 1 then
return t "<C-n>"
elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Plug>(vsnip-expand-or-jump)"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
else
return t "<S-Tab>"
end
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
return t "<S-Tab>"
end
end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
......
require('keybindings.compe')
require('keybindings.which_key')
--- local bind = require('keybindings.utility')
--- local map_cr = bind.map_cr
--- local map_cu = bind.map_cu
--- local map_cmd = bind.map_cmd
--- local map_args = bind.map_args
---
--- local mappings = {
--- ["n|<Leader>pu"] = map_cr("PackerUpdate"):with_silent():with_noremap():with_nowait(),
--- ["n|<Leader>ps"] = map_cr("PackerSync"):with_silent():with_noremap():with_nowait(),
--- ["n|<Leader>bb"] = map_cu("Telescope buffers"):with_noremap():with_silent(),
--- ["n|<Leader>ee"] = map_cu("Telescope file_browser"):with_noremap():with_silent(),
--- ["n|<Leader>ma"] = map_cu("Lspsaga code_action"):with_noremap():with_silent(),
--- ["n|<Leader>tt"] = map_cr("NvimTreeToggle"):with_noremap():with_silent(),
---
--- ["i|<CR>"] = map_cmd([[compe#confirm('<CR>')]]):with_noremap():with_expr():with_nowait(),
---
--- -- ["i|<CR>"] = map_cmd([[compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' })]]):with_noremap():with_expr():with_nowait(),
--- -- -- person keymap
--- -- ["n|mf"] = map_cr("<cmd>lua require('internal.fsevent').file_event()<CR>"):with_silent():with_nowait():with_noremap();
--- -- ["n|gb"] = map_cr("BufferLinePick"):with_noremap():with_silent(),
--- -- -- Packer
--- -- ["n|<leader>pu"] = map_cr("PackerUpdate"):with_silent():with_noremap():with_nowait();
--- -- ["n|<leader>pi"] = map_cr("PackerInstall"):with_silent():with_noremap():with_nowait();
--- -- ["n|<leader>pc"] = map_cr("PackerCompile"):with_silent():with_noremap():with_nowait();
--- -- -- Lsp mapp work when insertenter and lsp start
--- -- ["n|<leader>li"] = map_cr("LspInfo"):with_noremap():with_silent():with_nowait(),
--- -- ["n|<leader>ll"] = map_cr("LspLog"):with_noremap():with_silent():with_nowait(),
--- -- ["n|<leader>lr"] = map_cr("LspRestart"):with_noremap():with_silent():with_nowait(),
--- -- ["n|<C-f>"] = map_cmd("<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>"):with_silent():with_noremap():with_nowait(),
--- -- ["n|<C-b>"] = map_cmd("<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>"):with_silent():with_noremap():with_nowait(),
--- -- ["n|[e"] = map_cr('Lspsaga diagnostic_jump_next'):with_noremap():with_silent(),
--- -- ["n|]e"] = map_cr('Lspsaga diagnostic_jump_prev'):with_noremap():with_silent(),
--- -- ["n|K"] = map_cr("Lspsaga hover_doc"):with_noremap():with_silent(),
--- -- ["n|ga"] = map_cr("Lspsaga code_action"):with_noremap():with_silent(),
--- -- ["v|ga"] = map_cu("Lspsaga range_code_action"):with_noremap():with_silent(),
--- -- ["n|gd"] = map_cr('Lspsaga preview_definition'):with_noremap():with_silent(),
--- -- ["n|gD"] = map_cmd("<cmd>lua vim.lsp.buf.implementation()<CR>"):with_noremap():with_silent(),
--- -- ["n|gs"] = map_cr('Lspsaga signature_help'):with_noremap():with_silent(),
--- -- ["n|gr"] = map_cr('Lspsaga rename'):with_noremap():with_silent(),
--- -- ["n|gh"] = map_cr('Lspsaga lsp_finder'):with_noremap():with_silent(),
--- -- ["n|gt"] = map_cmd("<cmd>lua vim.lsp.buf.type_definition()<CR>"):with_noremap():with_silent(),
--- -- ["n|<Leader>cw"] = map_cmd("<cmd>lua vim.lsp.buf.workspace_symbol()<CR>"):with_noremap():with_silent(),
--- -- ["n|<Leader>ce"] = map_cr('Lspsaga show_line_diagnostics'):with_noremap():with_silent(),
--- -- ["n|<Leader>ct"] = map_args("Template"),
--- -- ["n|<Leader>tf"] = map_cu('DashboardNewFile'):with_noremap():with_silent(),
--- -- -- Plugin nvim-tree
--- -- ["n|<Leader>e"] = map_cr('NvimTreeToggle'):with_noremap():with_silent(),
--- -- ["n|<Leader>F"] = map_cr('NvimTreeFindFile'):with_noremap():with_silent(),
--- -- -- Plugin MarkdownPreview
--- -- ["n|<Leader>om"] = map_cu('MarkdownPreview'):with_noremap():with_silent(),
--- -- -- Plugin DadbodUI
--- -- ["n|<Leader>od"] = map_cr('DBUIToggle'):with_noremap():with_silent(),
--- -- -- Plugin Floaterm
--- -- ["n|<A-d>"] = map_cu('Lspsaga open_floaterm'):with_noremap():with_silent(),
--- -- ["t|<A-d>"] = map_cu([[<C-\><C-n>:Lspsaga close_floaterm<CR>]]):with_noremap():with_silent(),
--- -- ["n|<Leader>g"] = map_cu("Lspsaga open_floaterm lazygit"):with_noremap():with_silent(),
--- -- -- Far.vim
--- -- ["n|<Leader>fz"] = map_cr('Farf'):with_noremap():with_silent();
--- -- ["v|<Leader>fz"] = map_cr('Farf'):with_noremap():with_silent();
--- -- -- Plugin Telescope
--- -- ["n|<Leader>bb"] = map_cu('Telescope buffers'):with_noremap():with_silent(),
--- -- ["n|<Leader>fa"] = map_cu('DashboardFindWord'):with_noremap():with_silent(),
--- -- ["n|<Leader>fb"] = map_cu('Telescope file_browser'):with_noremap():with_silent(),
--- -- ["n|<Leader>ff"] = map_cu('DashboardFindFile'):with_noremap():with_silent(),
--- -- ["n|<Leader>fg"] = map_cu('Telescope git_files'):with_noremap():with_silent(),
--- -- ["n|<Leader>fw"] = map_cu('Telescope grep_string'):with_noremap():with_silent(),
--- -- ["n|<Leader>fh"] = map_cu('DashboardFindHistory'):with_noremap():with_silent(),
--- -- ["n|<Leader>fl"] = map_cu('Telescope loclist'):with_noremap():with_silent(),
--- -- ["n|<Leader>fc"] = map_cu('Telescope git_commits'):with_noremap():with_silent(),
--- -- ["n|<Leader>ft"] = map_cu('Telescope help_tags'):with_noremap():with_silent(),
--- -- ["n|<Leader>fd"] = map_cu('Telescope dotfiles path='..os.getenv("HOME")..'/.dotfiles'):with_noremap():with_silent(),
--- -- ["n|<Leader>fs"] = map_cu('Telescope gosource'):with_noremap():with_silent(),
--- -- -- prodoc
--- -- ["n|gcc"] = map_cu('ProComment'):with_noremap():with_silent(),
--- -- ["x|gcc"] = map_cr('ProComment'),
--- -- ["n|gcj"] = map_cu('ProDoc'):with_silent():with_silent(),
--- -- -- Plugin acceleratedjk
--- -- ["n|j"] = map_cmd('v:lua.enhance_jk_move("j")'):with_silent():with_expr(),
--- -- ["n|k"] = map_cmd('v:lua.enhance_jk_move("k")'):with_silent():with_expr(),
--- -- -- Plugin QuickRun
--- -- ["n|<Leader>r"] = map_cr("<cmd> lua require'internal.quickrun'.run_command()"):with_noremap():with_silent(),
--- -- -- Plugin Vista
--- -- ["n|<Leader>v"] = map_cu('Vista'):with_noremap():with_silent(),
--- -- -- Plugin vim-operator-surround
--- -- ["n|sa"] = map_cmd("<Plug>(operator-surround-append)"):with_silent(),
--- -- ["n|sd"] = map_cmd("<Plug>(operator-surround-delete)"):with_silent(),
--- -- ["n|sr"] = map_cmd("<Plug>(operator-surround-replace)"):with_silent(),
--- -- -- Plugin hrsh7th/vim-eft
--- -- ["n|;"] = map_cmd("v:lua.enhance_ft_move(';')"):with_expr(),
--- -- ["x|;"] = map_cmd("v:lua.enhance_ft_move(';')"):with_expr(),
--- -- ["n|f"] = map_cmd("v:lua.enhance_ft_move('f')"):with_expr(),
--- -- ["x|f"] = map_cmd("v:lua.enhance_ft_move('f')"):with_expr(),
--- -- ["o|f"] = map_cmd("v:lua.enhance_ft_move('f')"):with_expr(),
--- -- ["n|F"] = map_cmd("v:lua.enhance_ft_move('F')"):with_expr(),
--- -- ["x|F"] = map_cmd("v:lua.enhance_ft_move('F')"):with_expr(),
--- -- ["o|F"] = map_cmd("v:lua.enhance_ft_move('F')"):with_expr(),
--- -- -- Plugin vim_niceblock
--- -- ["x|I"] = map_cmd("v:lua.enhance_nice_block('I')"):with_expr(),
--- -- ["x|gI"] = map_cmd("v:lua.enhance_nice_block('gI')"):with_expr(),
--- -- ["x|A"] = map_cmd("v:lua.enhance_nice_block('A')"):with_expr(),
--- };
---
--- bind.nvim_load_mapping(mappings)
vim.api.nvim_set_keymap("i", "<c-x><c-s>", "<Esc><Cmd>w<CR>a", {silent = true, nowait = true})
vim.api.nvim_set_keymap("n", "<c-x><c-s>", "<Cmd>w<CR>", {silent = true})
local rhs_options = {}
vim.api.nvim_set_keymap("")
function rhs_options:new()
local instance = {
cmd = '',
options = {
noremap = false,
silent = false,
expr = false,
nowait = false,
local instance = {
cmd = '',
options = {
noremap = false,
silent = false,
expr = false,
nowait = false,
}
}
}
setmetatable(instance,self)
self.__index = self
return instance
setmetatable(instance,self)
self.__index = self
return instance
end
function rhs_options:map_cmd(cmd_string)
self.cmd = cmd_string
return self
self.cmd = cmd_string
return self
end
function rhs_options:map_cr(cmd_string)
self.cmd = (":%s<CR>"):format(cmd_string)
return self
self.cmd = (":%s<CR>"):format(cmd_string)
return self
end
function rhs_options:map_args(cmd_string)
self.cmd = (":%s<Space>"):format(cmd_string)
return self
self.cmd = (":%s<Space>"):format(cmd_string)
return self
end
function rhs_options:map_cu(cmd_string)
self.cmd = (":<C-u>%s<CR>"):format(cmd_string)
return self
self.cmd = (":<C-u>%s<CR>"):format(cmd_string)
return self
end
function rhs_options:with_silent()
self.options.silent = true
return self
self.options.silent = true
return self
end
function rhs_options:with_noremap()
self.options.noremap = true
return self
self.options.noremap = true
return self
end
function rhs_options:with_expr()
self.options.expr = true
return self
self.options.expr = true
return self
end
function rhs_options:with_nowait()
self.options.nowait = true
return self
self.options.nowait = true
return self
end
local pbind = {}
function pbind.map_cr(cmd_string)
local ro = rhs_options:new()
return ro:map_cr(cmd_string)
local ro = rhs_options:new()
return ro:map_cr(cmd_string)
end
function pbind.map_cmd(cmd_string)
local ro = rhs_options:new()
return ro:map_cmd(cmd_string)
local ro = rhs_options:new()
return ro:map_cmd(cmd_string)
end
function pbind.map_cu(cmd_string)
local ro = rhs_options:new()
return ro:map_cu(cmd_string)
local ro = rhs_options:new()
return ro:map_cu(cmd_string)
end
function pbind.map_args(cmd_string)
local ro = rhs_options:new()
return ro:map_args(cmd_string)
local ro = rhs_options:new()
return ro:map_args(cmd_string)
end
function pbind.nvim_load_mapping(mapping)
for key,value in pairs(mapping) do
local mode,keymap = key:match("([^|]*)|?(.*)")
if type(value) == 'table' then
local rhs = value.cmd
local options = value.options
vim.api.nvim_set_keymap(mode,keymap,rhs,options)
end
local mode,keymap = key:match("([^|]*)|?(.*)")
if type(value) == 'table' then
local rhs = value.cmd
local options = value.options
vim.api.nvim_set_keymap(mode,keymap,rhs,options)
end
end
end
......
......@@ -4,6 +4,7 @@ local keymap = {
f = {
name = '+file',
f = {'<Cmd>Telescope file_browser<CR>', 'browser'},
t = {'<Cmd>NvimTreeToggle<CR>', 'tree'},
},
b = {
......@@ -16,6 +17,23 @@ local keymap = {
u = {'<Cmd>PackerUpdate<CR>', 'update'},
s = {'<Cmd>PackerSync<CR>', 'sync'},
},
l = {
name = '+lsp',
a = {'<Cmd>Lspsaga code_action<CR>', 'code action'},
r = {'<Cmd>Lspsaga rename<CR>', 'rename'},
s = {'<Cmd>Lspsaga lsp_finder<CR>', 'find'},
p = {'<Cmd>Lspsaga preview_definition<CR>', 'preview definition'},
f = {'<Cmd>lua vim.lsp.buf.formatting()<CR>', 'format'},
},
t = {
name = '+telescope',
p = {'<Cmd>Telescope project<CR>', 'projects'},
}
}
wk.register_keymap('leader', keymap)
......
require('lspconfig').gopls.setup{}
local lsp_config = require('lspconfig')
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
lsp_config.gopls.setup{
capabilities = capabilities,
}
lsp_config.rust_analyzer.setup{
capabilities = capabilities,
}
......@@ -5,13 +5,19 @@ return require('packer').startup(function()
use {
'morhetz/gruvbox',
config = function()
vim.cmd[[colo gruvbox]]
end
-- config = function()
-- vim.cmd[[colo gruvbox]]
-- end
}
use 'icymind/NeoSolarized'
use 'romgrk/doom-one.vim'
use {
'romgrk/doom-one.vim',
-- config = function()
-- vim.cmd[[colo doom-one]]
-- end
}
-- UI
use 'ntpeters/vim-better-whitespace'
......@@ -62,6 +68,14 @@ return require('packer').startup(function()
};
}
end,
requires = {
{
'hrsh7th/vim-vsnip',
requires = {'hrsh7th/vim-vsnip-integ'}
}
}
}
use 'kyazdani42/nvim-tree.lua'
use {
......@@ -71,13 +85,46 @@ return require('packer').startup(function()
-- Utilities
use 'editorconfig/editorconfig-vim'
use {'tjdevries/colorbuddy.vim', {'nvim-treesitter/nvim-treesitter', opt = true}}
use 'tjdevries/colorbuddy.vim'
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
requires = {
'nvim-treesitter/nvim-treesitter-refactor',
'nvim-treesitter/nvim-treesitter-textobjects'
},
}
use {
'tjdevries/gruvbuddy.nvim',
config = function()
require('colorbuddy').colorscheme('gruvbuddy')
end
}
use {
'nvim-telescope/telescope.nvim',
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}
requires = {
{'nvim-lua/popup.nvim'},
{'nvim-lua/plenary.nvim'},
{'nvim-telescope/telescope-project.nvim'}
},
config = function()
require('telescope').load_extension('project')
end
}
use 'Chiel92/vim-autoformat'
use 'Raimondi/delimitMate'
use {
'Shougo/echodoc.vim',
config = function()
vim.cmd([[let g:echodoc#enable_at_startup = 1]])
end
}
-- LSP
use 'neovim/nvim-lspconfig'
......@@ -95,4 +142,42 @@ return require('packer').startup(function()
require('lspsaga').init_lsp_saga()
end
}
use {
'kosayoda/nvim-lightbulb',
config = function()
require('nvim-lightbulb').update_lightbulb {
sign = {
enabled = true,
-- Priority of the gutter sign
priority = 10,
},
float = {
enabled = true,
-- Text to show in the popup float
text = "💡",
-- Available keys for window options:
-- - height of floating window
-- - width of floating window
-- - wrap_at character to wrap at for computing height
-- - max_width maximal width of floating window
-- - max_height maximal height of floating window
-- - pad_left number of columns to pad contents at left
-- - pad_right number of columns to pad contents at right
-- - pad_top number of lines to pad contents at top
-- - pad_bottom number of lines to pad contents at bottom
-- - offset_x x-axis offset of the floating window
-- - offset_y y-axis offset of the floating window
-- - anchor corner of float to place at the cursor (NW, NE, SW, SE)
-- - winblend transparency of the window (0-100)
win_opts = {},
},
virtual_text = {
enabled = false,
-- Text to show at virtual text
text = "💡",
}
}
end
}
end)
local ts_configs = require('nvim-treesitter.configs')
ts_configs.setup {
ensure_installed = {
'bash', 'bibtex', 'c', 'comment', 'cpp', 'css', 'go', 'haskell',
'html', 'javascript', 'json', 'jsonc', 'julia', 'kotlin', 'latex', 'lua', 'ocaml',
'ocaml_interface', 'python', 'regex', 'rust', 'teal', 'toml', 'typescript', 'yaml', 'zig'
},
highlight = {enable = true, use_languagetree = true},
indent = {enable = false},
incremental_selection = {
enable = true,
keymaps = {
init_selection = 'gnn',
node_incremental = 'grn',
scope_incremental = 'grc',
node_decremental = 'grm'
}
},
refactor = {
smart_rename = {enable = true, keymaps = {smart_rename = "grr"}},
highlight_definitions = {enable = true}
-- highlight_current_scope = { enable = true }
},
textobjects = {
select = {
enable = true,
keymaps = {
['iF'] = {
python = '(function_definition) @function',
cpp = '(function_definition) @function',
c = '(function_definition) @function',
java = '(method_declaration) @function'
},
-- or you use the queries from supported languages with textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['aC'] = '@class.outer',
['iC'] = '@class.inner',
['ac'] = '@conditional.outer',
['ic'] = '@conditional.inner',
['ae'] = '@block.outer',
['ie'] = '@block.inner',
['al'] = '@loop.outer',
['il'] = '@loop.inner',
['is'] = '@statement.inner',
['as'] = '@statement.outer',
['ad'] = '@comment.outer',
['am'] = '@call.outer',
['im'] = '@call.inner'
}
}
}
}
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