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 -- Load all the configuration modules
require("core") require("core")
require("keybindings")
require("plugins") require("plugins")
require("lsp") require("lsp")
require("keybindings") require("treesitter")
...@@ -15,20 +15,24 @@ end ...@@ -15,20 +15,24 @@ end
--- move to prev/next item in completion menuone --- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder --- jump to prev/next snippet's placeholder
_G.tab_complete = function() _G.tab_complete = function()
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
return t "<C-n>" return t "<C-n>"
elseif check_back_space() then elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Tab>" return t "<Plug>(vsnip-expand-or-jump)"
else elseif check_back_space() then
return vim.fn['compe#complete']() return t "<Tab>"
end else
return vim.fn['compe#complete']()
end
end end
_G.s_tab_complete = function() _G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
return t "<C-p>" return t "<C-p>"
else elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<S-Tab>" return t "<Plug>(vsnip-jump-prev)"
end else
return t "<S-Tab>"
end
end end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
......
require('keybindings.compe') require('keybindings.compe')
require('keybindings.which_key') require('keybindings.which_key')
--- local bind = require('keybindings.utility') vim.api.nvim_set_keymap("i", "<c-x><c-s>", "<Esc><Cmd>w<CR>a", {silent = true, nowait = true})
--- local map_cr = bind.map_cr vim.api.nvim_set_keymap("n", "<c-x><c-s>", "<Cmd>w<CR>", {silent = true})
--- 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)
local rhs_options = {} local rhs_options = {}
vim.api.nvim_set_keymap("")
function rhs_options:new() function rhs_options:new()
local instance = { local instance = {
cmd = '', cmd = '',
options = { options = {
noremap = false, noremap = false,
silent = false, silent = false,
expr = false, expr = false,
nowait = false, nowait = false,
}
} }
} setmetatable(instance,self)
setmetatable(instance,self) self.__index = self
self.__index = self return instance
return instance
end end
function rhs_options:map_cmd(cmd_string) function rhs_options:map_cmd(cmd_string)
self.cmd = cmd_string self.cmd = cmd_string
return self return self
end end
function rhs_options:map_cr(cmd_string) function rhs_options:map_cr(cmd_string)
self.cmd = (":%s<CR>"):format(cmd_string) self.cmd = (":%s<CR>"):format(cmd_string)
return self return self
end end
function rhs_options:map_args(cmd_string) function rhs_options:map_args(cmd_string)
self.cmd = (":%s<Space>"):format(cmd_string) self.cmd = (":%s<Space>"):format(cmd_string)
return self return self
end end
function rhs_options:map_cu(cmd_string) function rhs_options:map_cu(cmd_string)
self.cmd = (":<C-u>%s<CR>"):format(cmd_string) self.cmd = (":<C-u>%s<CR>"):format(cmd_string)
return self return self
end end
function rhs_options:with_silent() function rhs_options:with_silent()
self.options.silent = true self.options.silent = true
return self return self
end end
function rhs_options:with_noremap() function rhs_options:with_noremap()
self.options.noremap = true self.options.noremap = true
return self return self
end end
function rhs_options:with_expr() function rhs_options:with_expr()
self.options.expr = true self.options.expr = true
return self return self
end end
function rhs_options:with_nowait() function rhs_options:with_nowait()
self.options.nowait = true self.options.nowait = true
return self return self
end end
local pbind = {} local pbind = {}
function pbind.map_cr(cmd_string) function pbind.map_cr(cmd_string)
local ro = rhs_options:new() local ro = rhs_options:new()
return ro:map_cr(cmd_string) return ro:map_cr(cmd_string)
end end
function pbind.map_cmd(cmd_string) function pbind.map_cmd(cmd_string)
local ro = rhs_options:new() local ro = rhs_options:new()
return ro:map_cmd(cmd_string) return ro:map_cmd(cmd_string)
end end
function pbind.map_cu(cmd_string) function pbind.map_cu(cmd_string)
local ro = rhs_options:new() local ro = rhs_options:new()
return ro:map_cu(cmd_string) return ro:map_cu(cmd_string)
end end
function pbind.map_args(cmd_string) function pbind.map_args(cmd_string)
local ro = rhs_options:new() local ro = rhs_options:new()
return ro:map_args(cmd_string) return ro:map_args(cmd_string)
end end
function pbind.nvim_load_mapping(mapping) function pbind.nvim_load_mapping(mapping)
for key,value in pairs(mapping) do for key,value in pairs(mapping) do
local mode,keymap = key:match("([^|]*)|?(.*)") local mode,keymap = key:match("([^|]*)|?(.*)")
if type(value) == 'table' then if type(value) == 'table' then
local rhs = value.cmd local rhs = value.cmd
local options = value.options local options = value.options
vim.api.nvim_set_keymap(mode,keymap,rhs,options) vim.api.nvim_set_keymap(mode,keymap,rhs,options)
end end
end end
end end
......
...@@ -4,6 +4,7 @@ local keymap = { ...@@ -4,6 +4,7 @@ local keymap = {
f = { f = {
name = '+file', name = '+file',
f = {'<Cmd>Telescope file_browser<CR>', 'browser'}, f = {'<Cmd>Telescope file_browser<CR>', 'browser'},
t = {'<Cmd>NvimTreeToggle<CR>', 'tree'},
}, },
b = { b = {
...@@ -16,6 +17,23 @@ local keymap = { ...@@ -16,6 +17,23 @@ local keymap = {
u = {'<Cmd>PackerUpdate<CR>', 'update'}, u = {'<Cmd>PackerUpdate<CR>', 'update'},
s = {'<Cmd>PackerSync<CR>', 'sync'}, 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) 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() ...@@ -5,13 +5,19 @@ return require('packer').startup(function()
use { use {
'morhetz/gruvbox', 'morhetz/gruvbox',
config = function() -- config = function()
vim.cmd[[colo gruvbox]] -- vim.cmd[[colo gruvbox]]
end -- end
} }
use 'icymind/NeoSolarized' use 'icymind/NeoSolarized'
use 'romgrk/doom-one.vim' use {
'romgrk/doom-one.vim',
-- config = function()
-- vim.cmd[[colo doom-one]]
-- end
}
-- UI -- UI
use 'ntpeters/vim-better-whitespace' use 'ntpeters/vim-better-whitespace'
...@@ -62,6 +68,14 @@ return require('packer').startup(function() ...@@ -62,6 +68,14 @@ return require('packer').startup(function()
}; };
} }
end, end,
requires = {
{
'hrsh7th/vim-vsnip',
requires = {'hrsh7th/vim-vsnip-integ'}
}
}
} }
use 'kyazdani42/nvim-tree.lua' use 'kyazdani42/nvim-tree.lua'
use { use {
...@@ -71,13 +85,46 @@ return require('packer').startup(function() ...@@ -71,13 +85,46 @@ return require('packer').startup(function()
-- Utilities -- Utilities
use 'editorconfig/editorconfig-vim' 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 { use {
'nvim-telescope/telescope.nvim', '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 'Chiel92/vim-autoformat'
use 'Raimondi/delimitMate'
use {
'Shougo/echodoc.vim',
config = function()
vim.cmd([[let g:echodoc#enable_at_startup = 1]])
end
}
-- LSP -- LSP
use 'neovim/nvim-lspconfig' use 'neovim/nvim-lspconfig'
...@@ -95,4 +142,42 @@ return require('packer').startup(function() ...@@ -95,4 +142,42 @@ return require('packer').startup(function()
require('lspsaga').init_lsp_saga() require('lspsaga').init_lsp_saga()
end 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) 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