feat: add nvim

This commit is contained in:
2022-01-16 15:05:09 +08:00
parent f66e4a5f6b
commit 364134990d
78 changed files with 4144 additions and 821 deletions
+3
View File
@@ -0,0 +1,3 @@
vim.api.nvim_set_keymap('n', '<TAB>', ':BufferNext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferPrevious<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-x>', ':BufferClose<CR>', { noremap = true, silent = true })
+63
View File
@@ -0,0 +1,63 @@
--[[
local dashboard = {
custom_header = {
' _..._ ',
' .\' (_`. _ __ ___ ',
' : . : | | _ _ _ __ __ _ _ _\\ \\ / (_)_ __ ___ ',
' :) () : | | | | | | \'_ \\ / _` | \'__\\ \\ / /| | \'_ ` _ \\ ',
' `. . .\' | |__| |_| | | | | (_| | | \\ V / | | | | | | |',
' `-...-\' |_____\\__,_|_| |_|\\__,_|_| \\_/ |_|_| |_| |_|',
},
footer= {'Laily'}
}
]]
local dashboard = {
custom_header = {
'███╗ ██╗██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗',
'████╗ ██║██║ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝',
'██╔██╗ ██║██║ ██║██║ ██║ ██║██║ ██║█████╗',
'██║╚██╗██║╚██╗ ██╔╝██║ ██║ ██║██║ ██║██╔══╝',
'██║ ╚████║ ╚████╔╝ ╚██████╗╚██████╔╝██████╔╝███████╗',
'╚═╝ ╚═══╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝'
},
footer= {'Laily'},
}
-- vim.g.dashboard_custom_header = {
--
-- ' _..._ ',
-- ' .\' `. ██  ██  ██ ███  ██  █████  ██████  ██  ██ ██ ███  ███ ',
-- ' : : ██  ██  ██ ████  ██ ██   ██ ██   ██ ██  ██ ██ ████  ████ ',
-- ' : : ██  ██  ██ ██ ██  ██ ███████ ██████  ██  ██ ██ ██ ████ ██ ',
-- ' `. .\' ██  ██  ██ ██  ██ ██ ██   ██ ██   ██  ██  ██  ██ ██  ██  ██ ',
-- ' `-...-\' ███████  ██████  ██   ████ ██  ██ ██  ██   ████   ██ ██      ██ ',
--
-- }
vim.g.dashboard_custom_header = dashboard.custom_header
vim.g.dashboard_default_executive = 'telescope'
vim.g.dashboard_custom_section = {
a = {description = {' Find File '}, command = 'Telescope find_files'},
b = {description = {' Recently Used Files'}, command = 'Telescope oldfiles'},
c = {description = {' Load Last Session '}, command = 'SessionLoad'},
d = {description = {' Find Word '}, command = 'Telescope live_grep'},
e = {description = {' Settings '}, command = ':e '..CONFIG_PATH..'/lv-settings.lua'}
-- e = {description = {' Marks '}, command = 'Telescope marks'}
}
-- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'},
-- vim.g.dashboard_custom_shortcut = {
-- a = 'f',
-- find_word = 'SPC f a',
-- last_session = 'SPC s l',
-- new_file = 'SPC c n',
-- book_marks = 'SPC f b'
-- }
-- find_history = 'SPC f h',
-- vim.g.dashboard_session_directory = CACHE_PATH..'/session'
vim.g.dashboard_custom_footer = dashboard.footer
+11
View File
@@ -0,0 +1,11 @@
require'fzf-lua'.setup {
fzf_opts = { ['--keep-right'] = ''},
fzf_cli_args = '--keep-right',
--[[
winopts = {
preview = {
layout = "vertical"
}
}
]]
}
+220
View File
@@ -0,0 +1,220 @@
local gl = require('galaxyline')
-- get my theme in galaxyline repo
-- local colors = require('galaxyline.theme').default
local colors = {
-- bg = '#2E2E2E',
bg = '#292D38',
yellow = '#DCDCAA',
dark_yellow = '#D7BA7D',
cyan = '#4EC9B0',
green = '#608B4E',
light_green = '#B5CEA8',
string_orange = '#CE9178',
orange = '#FF8800',
purple = '#C586C0',
magenta = '#D16D9E',
grey = '#858585',
blue = '#569CD6',
vivid_blue = '#4FC1FF',
light_blue = '#9CDCFE',
red = '#D16969',
error_red = '#F44747',
info_yellow = '#FFCC66'
}
local condition = require('galaxyline.condition')
local gls = gl.section
gl.short_line_list = {'NvimTree', 'vista', 'dbui', 'packer'}
table.insert(gls.left, {
ViMode = {
provider = function()
-- auto change color according the vim mode
local mode_color = {
n = colors.blue,
i = colors.green,
v = colors.purple,
[''] = colors.purple,
V = colors.purple,
c = colors.magenta,
no = colors.blue,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.red,
Rv = colors.red,
cv = colors.blue,
ce = colors.blue,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.blue,
t = colors.blue
}
vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
return '▊ '
end,
highlight = {colors.red, colors.bg}
}
})
print(vim.fn.getbufvar(0, 'ts'))
vim.fn.getbufvar(0, 'ts')
table.insert(gls.left, {
GitIcon = {
provider = function()
return ''
end,
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.orange, colors.bg}
}
})
table.insert(gls.left, {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.left, {
DiffAdd = {
provider = 'DiffAdd',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.green, colors.bg}
}
})
table.insert(gls.left, {
DiffModified = {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = ' 柳',
highlight = {colors.blue, colors.bg}
}
})
table.insert(gls.left, {
DiffRemove = {
provider = 'DiffRemove',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.red, colors.bg}
}
})
table.insert(gls.right, {
DiagnosticError = {provider = 'DiagnosticError', icon = '', highlight = {colors.error_red, colors.bg}}
})
table.insert(gls.right, {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '', highlight = {colors.orange, colors.bg}}})
table.insert(gls.right, {
DiagnosticHint = {provider = 'DiagnosticHint', icon = '', highlight = {colors.vivid_blue, colors.bg}}
})
table.insert(gls.right, {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '', highlight = {colors.info_yellow, colors.bg}}})
table.insert(gls.right, {
TreesitterIcon = {
provider = function()
if next(vim.treesitter.highlighter.active) ~= nil then return '' end
return ''
end,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.green, colors.bg}
}
})
table.insert(gls.right, {
ShowLspClient = {
provider = 'GetLspClient',
condition = function()
local tbl = {['dashboard'] = true, [' '] = true}
if tbl[vim.bo.filetype] then return false end
return true
end,
icon = '',
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
LineInfo = {
provider = 'LineColumn',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
PerCent = {
provider = 'LinePercent',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
Tabstop = {
provider = function()
return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
end,
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
BufferType = {
provider = 'FileTypeName',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
FileEncode = {
provider = 'FileEncode',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.right, {
Space = {
provider = function()
return ' '
end,
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.orange, colors.bg}
}
})
table.insert(gls.short_line_left, {
BufferType = {
provider = 'FileTypeName',
separator = ' ',
separator_highlight = {'NONE', colors.bg},
highlight = {colors.grey, colors.bg}
}
})
table.insert(gls.short_line_left, {
SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}}
})
--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})
+24
View File
@@ -0,0 +1,24 @@
require('gitsigns').setup {
signs = {
-- TODO add hl to colorscheme
add = {hl = 'GitSignsAdd' , text = '▎', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
changedelete = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
},
numhl = false,
linehl = false,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
},
watch_index = {
interval = 1000
},
sign_priority = 6,
update_debounce = 200,
status_formatter = nil, -- Use default
use_decoration_api = false
}
+2
View File
@@ -0,0 +1,2 @@
vim.api.nvim_set_keymap('n', 's', ":HopChar2<cr>", {silent = true})
vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", {silent = true})
+35
View File
@@ -0,0 +1,35 @@
-- source plugin config
require('pluginconfig/barbar')
require('pluginconfig/dashboard-nvim')
require('pluginconfig/galaxyline')
require('pluginconfig/gitsigns')
require('pluginconfig/hop')
-- require('pluginconfig/lspinstall')
require('pluginconfig/numb')
require('pluginconfig/nvim-autopairs')
require('pluginconfig/nvim-colorizer')
require('pluginconfig/nvim-compe')
require('pluginconfig/fzf-lua')
require('pluginconfig/nvim-tree') -- This plugin must be required somewhere before colorscheme. Placing it after will break navigation keymappings
require('pluginconfig/nvim-treesitter')
require('pluginconfig/rnvimr')
require('pluginconfig/symbols-outline')
require('pluginconfig/telescope')
require('pluginconfig/toggleterm')
require('pluginconfig/vim-matchup')
require('pluginconfig/which-key')
-- nvim_comment
require('nvim_comment').setup()
-- lsp-rooter
require("lsp-rooter").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
-- lsp signature
require("lsp_signature").setup()
+27
View File
@@ -0,0 +1,27 @@
-- 1. get the config for this server from nvim-lspconfig and adjust the cmd path.
-- relative paths are allowed, lspinstall automatically adjusts the cmd and cmd_cwd for us!
local config = require'lspconfig'.jdtls.document_config
require'lspconfig/configs'.jdtls = nil -- important, unset the loaded config again
-- config.default_config.cmd[1] = "./node_modules/.bin/bash-language-server"
-- 2. extend the config with an install_script and (optionally) uninstall_script
require'lspinstall/servers'.jdtls = vim.tbl_extend('error', config, {
-- lspinstall will automatically create/delete the install directory for every server
install_script = [[
git clone https://github.com/eclipse/eclipse.jdt.ls.git
cd eclipse.jdt.ls
./mvnw clean verify
]],
uninstall_script = nil -- can be omitted
})
require'lspinstall/servers'.kotlin = vim.tbl_extend('error', config, {
install_script = [[
git clone https://github.com/fwcd/kotlin-language-server.git language-server
cd language-server
./gradlew :server:installDist
]],
uninstall_script = nil -- can be omitted
})
require'lspinstall'.setup()
+4
View File
@@ -0,0 +1,4 @@
require('numb').setup{
show_numbers = true, -- Enable 'number' for the window while peeking
show_cursorline = true -- Enable 'cursorline' for the window while peeking
}
+123
View File
@@ -0,0 +1,123 @@
-- require('nvim-autopairs').setup()
-- local npairs = require('nvim-autopairs')
-- local function imap(lhs, rhs, opts)
-- local options = {noremap = false}
-- if opts then options = vim.tbl_extend('force', options, opts) end
-- vim.api.nvim_set_keymap('i', lhs, rhs, options)
-- end
-- _G.MUtils = {}
-- -- TEST
-- vim.g.completion_confirm_key = ""
-- MUtils.completion_confirm = function()
-- if vim.fn.pumvisible() ~= 0 then
-- if vim.fn.complete_info()["selected"] ~= -1 then
-- vim.fn["compe#confirm"]()
-- -- return npairs.esc("<c-y>")
-- return npairs.esc("")
-- else
-- vim.defer_fn(function()
-- vim.fn["compe#confirm"]("<cr>")
-- end, 20)
-- return npairs.esc("<c-n>")
-- end
-- else
-- return npairs.check_break_line_char()
-- end
-- end
-- -- TEST
-- MUtils.completion_confirm = function()
-- if vim.fn.pumvisible() ~= 0 then
-- if vim.fn.complete_info()["selected"] ~= -1 then
-- vim.fn["compe#confirm"]()
-- return npairs.esc("")
-- else
-- vim.api.nvim_select_popupmenu_item(0, false, false, {})
-- vim.fn["compe#confirm"]()
-- return npairs.esc("<c-n>")
-- end
-- else
-- return npairs.check_break_line_char()
-- end
-- end
-- MUtils.tab = function()
-- if vim.fn.pumvisible() ~= 0 then
-- return npairs.esc("<C-n>")
-- else
-- if vim.fn["vsnip#available"](1) ~= 0 then
-- vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83))
-- return npairs.esc("")
-- else
-- return npairs.esc("<Tab>")
-- end
-- end
-- end
-- MUtils.s_tab = function()
-- if vim.fn.pumvisible() ~= 0 then
-- return npairs.esc("<C-p>")
-- else
-- if vim.fn["vsnip#jumpable"](-1) ~= 0 then
-- vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83))
-- return npairs.esc("")
-- else
-- return npairs.esc("<C-h>")
-- end
-- end
-- end
-- -- Autocompletion and snippets
-- vim.api.nvim_set_keymap('i', '<CR>', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true})
-- -- imap("<CR>", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true})
-- imap("<Tab>", "v:lua.MUtils.tab()", {expr = true, noremap = true})
-- imap("<S-Tab>", "v:lua.MUtils.s_tab()", {expr = true, noremap = true})
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
local Rule = require('nvim-autopairs.rule')
-- skip it, if you use another global object
_G.MUtils= {}
vim.g.completion_confirm_key = ""
MUtils.completion_confirm=function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info()["selected"] ~= -1 then
return vim.fn["compe#confirm"](npairs.esc("<cr>"))
else
return npairs.esc("<cr>")
end
else
return npairs.autopairs_cr()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
npairs.setup({
check_ts = true,
ts_config = {
lua = {'string'},-- it will not add pair on that treesitter node
javascript = {'template_string'},
java = false,-- don't check treesitter on java
}
})
require('nvim-treesitter.configs').setup {
autopairs = {enable = true}
}
local ts_conds = require('nvim-autopairs.ts-conds')
-- press % => %% is only inside comment or string
npairs.add_rules({
Rule("%", "%", "lua")
:with_pair(ts_conds.is_ts_node({'string','comment'})),
Rule("$", "$", "lua")
:with_pair(ts_conds.is_not_ts_node({'function'}))
})
+13
View File
@@ -0,0 +1,13 @@
require'colorizer'.setup(
{'*';},
{
RGB = true; -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes
RRGGBBAA = true; -- #RRGGBBAA hex codes
rgb_fn = true; -- CSS rgb() and rgba() functions
hsl_fn = true; -- CSS hsl() and hsla() functions
css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn
})
-- names = true; -- "Name" codes like Blue
+150
View File
@@ -0,0 +1,150 @@
vim.o.completeopt = "menuone,noselect"
require'compe'.setup {
enabled = true,
autocomplete = true,
debug = false,
min_length = 1,
preselect = 'enable',
throttle_time = 80,
source_timeout = 200,
incomplete_delay = 400,
max_abbr_width = 100,
max_kind_width = 100,
max_menu_width = 100,
documentation = true,
source = {
path = {kind = "  (Path)"},
buffer = {kind = "  (Buffer)"},
calc = {kind = "  (Calc)"},
vsnip = {kind = "  (Snippet)"},
nvim_lsp = {kind = "  (LSP)"},
-- nvim_lua = {kind = "  "},
nvim_lua = false,
spell = {kind = "  (Spell)"},
tags = false,
vim_dadbod_completion = true,
-- snippets_nvim = {kind = "  "},
-- ultisnips = {kind = "  "},
-- treesitter = {kind = "  "},
emoji = {kind = " ﲃ (Emoji)", filetypes={"markdown", "text"}}
-- for emoji press : (idk if that in compe tho)
}
}
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- 
-- ﬘
-- 
-- 
-- 
-- m
-- 
-- 
-- 
-- 
-- local t = function(str)
-- return vim.api.nvim_replace_termcodes(str, true, true, true)
-- end
-- local check_back_space = function()
-- local col = vim.fn.col('.') - 1
-- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
-- return true
-- else
-- return false
-- end
-- end
-- -- Use (s-)tab to:
-- --- 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 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>"
-- 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})
-- vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = 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 t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local check_back_space = function()
local col = vim.fn.col('.') - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
return true
else
return false
end
end
-- Use (s-)tab to:
--- 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 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>"
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})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = 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})
+75
View File
@@ -0,0 +1,75 @@
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
require'nvim-tree'.setup {
disable_netrw = true,
hijack_netrw = true,
auto_close = false,
filters = {
dotfiles = false,
custom = {}
},
git = {
enable = true,
ignore = false,
timeout = 500,
},
update_focused_file = {
-- enables the feature
enable = false,
-- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory
-- only relevant when `update_focused_file.enable` is true
update_cwd = false,
-- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory
-- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true
ignore_list = {}
},
view = {
mappings = {
custome_only= false,
list = {
-- ["<CR>"] = ":YourVimFunction()<cr>",
-- ["u"] = ":lua require'some_module'.some_function()<cr>",
-- default mappings
{key="<CR>" ,cb= tree_cb("edit")},
{key="o" ,cb= tree_cb("edit")},
{key="l" ,cb= tree_cb("edit")},
{key="<2-LeftMouse>" ,cb= tree_cb("edit")},
{key="<2-RightMouse>" ,cb= tree_cb("cd")},
{key="<C->" ,cb= tree_cb("cd")},
{key="v" ,cb= tree_cb("vsplit")},
{key="s" ,cb= tree_cb("split")},
{key="<C-t>" ,cb= tree_cb("tabnew")},
{key="<" ,cb= tree_cb("prev_sibling")},
{key=">" ,cb= tree_cb("next_sibling")},
{key="<BS>" ,cb= tree_cb("close_node")},
{key="h" ,cb= tree_cb("close_node")},
{key="<S-CR>" ,cb= tree_cb("close_node")},
{key="<Tab>" ,cb= tree_cb("preview")},
{key="I" ,cb= tree_cb("toggle_ignored")},
{key="H" ,cb= tree_cb("toggle_dotfiles")},
{key="R" ,cb= tree_cb("refresh")},
{key="a" ,cb= tree_cb("create")},
{key="d" ,cb= tree_cb("remove")},
{key="r" ,cb= tree_cb("rename")},
{key="<C-r>" ,cb= tree_cb("full_rename")},
{key="x" ,cb= tree_cb("cut")},
{key="c" ,cb= tree_cb("copy")},
{key="p" ,cb= tree_cb("paste")},
{key="[c" ,cb= tree_cb("prev_git_item")},
{key="c" ,cb= tree_cb("next_git_item")},
{key="-" ,cb= tree_cb("dir_up")},
{key="q" ,cb= tree_cb("close")},
}
}
}
}
vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open
vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes.
vim.g.nvim_tree_icons = {
default = '',
symlink = '',
git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""},
folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""}
}
+30
View File
@@ -0,0 +1,30 @@
local treesitter = {
ensure_installed = "all",
ignore_install = {"haskell"},
highlight = {enabled = true},
playground = {enabled = true},
rainbow = {enabled = false},
}
require'nvim-treesitter.configs'.setup {
ensure_installed = treesitter.ensure_installed, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = treesitter.ignore_install,
matchup = {
enable = true, -- mandatory, false will disable the whole extension
-- disable = { "c", "ruby" }, -- optional, list of language that will be disabled
},
highlight = {
enable = treesitter.highlight.enabled -- false will disable the whole extension
},
context_commentstring = {
enable = true,
config = {
css = '// %s'
}
},
-- indent = {enable = true, disable = {"python", "html", "javascript"}},
-- TODO seems to be broken
indent = {enable = {"javascriptreact"}},
autotag = {enable = true},
}
+6
View File
@@ -0,0 +1,6 @@
-- Make Ranger replace netrw and be the file explorer
-- vim.g.rnvimr_ex_enable = 1
vim.g.rnvimr_draw_border = 1
vim.g.rnvimr_pick_enable = 1
vim.g.rnvimr_bw_enable = 1
vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle<CR>', {noremap = true, silent = true})
+15
View File
@@ -0,0 +1,15 @@
vim.g.symbols_outline = {
highlight_hovered_item = true,
show_guides = true,
auto_preview = true,
position = 'right',
keymaps = {
close = "<Esc>",
goto_location = "<Cr>",
focus_location = "o",
hover_symbol = "<C-space>",
rename_symbol = "r",
code_actions = "a",
},
lsp_blacklist = {},
}
+81
View File
@@ -0,0 +1,81 @@
local actions = require('telescope.actions')
local trouble = require("trouble.providers.telescope")
-- Global remapping
------------------------------
-- '--color=never',
require('telescope').setup {
defaults = {
--find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
vimgrep_arguments = { 'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' },
-- prompt_prefix = " ",
prompt_prefix = "",
selection_caret = "",
entry_prefix = " ",
initial_mode = "insert",
-- initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "descending",
layout_strategy = "horizontal",
layout_config= {horizontal = {mirror = false}, vertical = {mirror = false}, width = 0.75,prompt_position = "bottom", preview_cutoff = 120},
file_sorter = require'telescope.sorters'.get_fzy_sorter,
file_ignore_patterns = {},
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
-- shorten_path = true,
path_display = {shroten = 2},
winblend = 0,
border = {},
borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'},
color_devicons = true,
use_less = true,
set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil,
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
mappings = {
i = {
["<C-c>"] = actions.close,
["<ESC>"] = actions.close,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<c-t>"] = trouble.open_with_trouble,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
-- ["<c-x>"] = false,
-- ["<esc>"] = actions.close,
-- Otherwise, just set the mapping to the function that you want it to be.
-- ["<C-i>"] = actions.select_horizontal,
-- Add up multiple actions
["<CR>"] = actions.select_default + actions.center
-- You can perform as many actions in a row as you like
-- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
},
n = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<c-t>"] = trouble.open_with_trouble,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist
-- ["<C-i>"] = my_cool_custom_action,
}
}
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
}
}
}
require('telescope').load_extension('fzf')
require'telescope'.load_extension('project')
require("telescope").load_extension "file_browser"
+50
View File
@@ -0,0 +1,50 @@
require("toggleterm").setup{
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<c-\>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
shade_terminals = true,
shading_factor = '<number>', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
persist_size = true,
-- direction = 'vertical' | 'horizontal' | 'window' | 'float',
direction = 'float',
close_on_exit = true, -- close the terminal window when the process exits
shell = vim.o.shell, -- change the default shell
-- This field is only relevant if direction is set to 'float'
float_opts = {
-- The border key is *almost* the same as 'nvim_open_win'
-- see :h nvim_open_win for details on borders however
-- the 'curved' border is a custom border type
-- not natively supported but implemented in this plugin.
-- border = 'single' | 'double' | 'shadow' | 'curved' -- ... other options supported by win open
border = 'single',
-- width = <value>,
-- height = <value>,
winblend = 3,
highlights = {
border = "Normal",
background = "Normal",
}
}
}
-- function _G.set_terminal_keymaps()
-- local opts = {noremap = true}
-- vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
-- vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
-- vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
-- vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
-- vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
-- vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
-- end
-- vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
+2
View File
@@ -0,0 +1,2 @@
vim.g.matchup_matchparen_offscreen = {method = 'popup'}
+243
View File
@@ -0,0 +1,243 @@
require("which-key").setup {
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = false, -- adds help for operators like d, y, ...
motions = false, -- adds help for motions
text_objects = false, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true -- bindings for prefixed with g
}
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "➜", -- symbol used between a key and it's label
group = "+" -- symbol prepended to a group
},
window = {
border = "single", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = {1, 0, 1, 0}, -- extra window margin [top, right, bottom, left]
padding = {2, 2, 2, 2} -- extra window padding [top, right, bottom, left]
},
layout = {
height = {min = 4, max = 25}, -- min and max height of the columns
width = {min = 20, max = 50}, -- min and max width of the columns
spacing = 3 -- spacing between columns
},
hidden = {"<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
show_help = true -- show help message on the command line when the popup is visible
}
local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = false -- use `nowait` when creating keymaps
}
-- Set leader
vim.api.nvim_set_keymap('n', '<Space>', '<NOP>', {noremap = true, silent = true})
vim.g.mapleader = ' '
-- no hl
vim.api.nvim_set_keymap('n', '<Leader>h', ':set hlsearch!<CR>', {noremap = true, silent = true})
-- explorer
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
-- telescope
--vim.api.nvim_set_keymap('n', '<C-p>', ":lua require 'telescope'.extensions.file_browser.file_browser()<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap('n', '<C-p>', ":lua require'telescope.builtin'.find_files()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<C-p>', ":FzfLua files<CR>", {noremap = true, silent = true})
-- dashboard
vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>', {noremap = true, silent = true})
-- Comments
vim.api.nvim_set_keymap("n", "<Leader>b/", ":CommentToggle<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("v", "<Leader>b/", ":CommentToggle<CR>", {noremap = true, silent = true})
-- close buffer
vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", {noremap = true, silent = true})
-- open projects
--vim.api.nvim_set_keymap('n', '<leader>p', ":lua require'telescope'.extensions.project.project{}<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap('n', '<leader>p', ":lua require 'telescope'.extensions.file_browser.file_browser()<CR>", {noremap = true, silent = true})
-- TODO create entire treesitter section
local mappings = {
-- ["/"] = "Comment",
-- ["c"] = "Close Buffer",
["e"] = "Explorer",
-- ["f"] = "Find File",
["h"] = "No Highlight",
a = {
name = "+Action",
a = {"<cmd>@:<cr>","execute last command again"}
},
b = {
name = "+Buffer",
n = {"<cmd>BufferNext<cr>", "next buffer"},
p = {"<cmd>BufferPrevious<cr>", "previous buffer"},
q = {"<cmd>q<cr>", "quit"},
s = {"<cmd>w<cr>", "save"},
r = {"<cmd>e!<cr>", "reload"},
d = {"<cmd>BufferClose<cr>", "close buffer"},
z = {"<cmd>CommentToggle<CR>", "toggle comment"},
},
D = {
name = "+Diagnostics",
t = {"<cmd>TroubleToggle<cr>", "trouble"},
w = {"<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace"},
d = {"<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document"},
q = {"<cmd>TroubleToggle quickfix<cr>", "quickfix"},
l = {"<cmd>TroubleToggle loclist<cr>", "loclist"},
r = {"<cmd>TroubleToggle lsp_references<cr>", "references"},
},
d = {
name = "+Debug",
-- b = {"<cmd>DebugToggleBreakpoint<cr>", "Toggle Breakpoint"},
-- c = {"<cmd>DebugContinue<cr>", "Continue"},
-- i = {"<cmd>DebugStepInto<cr>", "Step Into"},
-- o = {"<cmd>DebugStepOver<cr>", "Step Over"},
-- r = {"<cmd>DebugToggleRepl<cr>", "Toggle Repl"},
-- s = {"<cmd>DebugStart<cr>", "Start"}
d = {"<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", "show diagnostics"},
c = {"<cmd>lua require'dap'.continue()<cr>", "continue"},
b = {':lua require"dap".toggle_breakpoint()<CR>', "Toggle Breadpoint"},
j = {':lua require"dap".step_over()<CR>', "step over"},
k = {':lua require"dap".step_out()<CR>', "step out"},
l = {':lua require"dap".step_into()<CR>',"step into"},
--<c-h>', ':lua require"dap".continue()<CR>')
u = {':lua require"dap".up()<CR>', "up"},
-- d = {':lua require"dap".down()<CR>', "down"},
_ = {':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()<CR>', "disconnect"},
--r = {':lua require"dap".repl.open({}, "vsplit")<CR><C-w>l', "repl open"},
i = {':lua require"dap.ui.variables".visual_hover()<CR>',"visual_hover"},
--? = {':lua require"dap.ui.variables".scopes()<CR>',"scopes"},
-- e = {':lua require"dap".set_exception_breakpoints({"all"})<CR>',"esception bp"},
-- a = {':lua require"debugHelper".attach()<CR>',"attach"},
-- A = {':lua require"debugHelper".attachToRemote()<CR>',"attach to remote"},
s = {':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)<CR>',"centered_float"},
},
f = {
name = "+File",
s = {"<cmd>w<cr>", "save file"},
t = {"<cmd>NvimTreeToggle<cr>", "toggle nvim tree"},
r = {"<cmd>RnvimrToggle<cr>", "toggle rnvimr"},
y = {"<cmd>lua require'utils'.yank_filepath()<cr>", "copy the file path"},
l = {"<cmd>NvimTreeFindFile<CR>", "find file"},
-- T = {"<cmd>let @+ = 'go test -v -run='+expand('<cword>')<cr>", "get current word in go test"},
},
g = {
name = "+Git",
j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
u = {
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
"Undo Stage Hunk",
},
o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
C = {
"<cmd>Telescope git_bcommits<cr>",
"Checkout commit(for current file)",
},
d = {
"<cmd>Gitsigns diffthis HEAD<cr>",
"Git Diff",
},
},
l = {
name = "+Language",
a = {"<cmd>Lspsaga code_action<cr>", "Code Action"},
A = {"<cmd>Lspsaga range_code_action<cr>", "Selected Action"},
d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
f = {"<cmd>LspFormatting<cr>", "Format"},
-- i = {"<cmd>Telescope lsp_implementations<cr>", "implement"},
i = {"<cmd>lua vim.lsp.buf.implementation()<cr>", "implement"},
F = {"<cmd>Lspsaga lsp_finder<cr>", "LSP Finder"},
L = {"<cmd>Lspsaga show_line_diagnostics<cr>", "Line Diagnostics"},
l = {"<cmd>lua vim.lsp.buf.hover()<cr>", "hover"},
P = {"<cmd>Lspsaga preview_definition<cr>", "Preview Definition"},
n = {"<cmd>lua vim.lsp.diagnostic.goto_next()<cr>", "next diagnostic"},
p = {"<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>", "prev diagnostic"},
q = {"<cmd>Telescope quickfix<cr>", "Quickfix"},
r = {"<cmd>lua vim.lsp.buf.references()<cr>", "references"},
R = {"<cmd>Lspsaga rename<cr>", "Rename"},
t = {"<cmd>LspTypeDefinition<cr>", "Type Definition"},
x = {"<cmd>cclose<cr>", "Close Quickfix"},
s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"},
S = {"<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", "Workspace Symbols"},
z = {"<cmd>LspInfo<cr>", "Info"},
},
p = {
name = "Packer",
c = { "<cmd>PackerCompile<cr>", "Compile" },
i = { "<cmd>PackerInstall<cr>", "Install" },
s = { "<cmd>PackerSync<cr>", "Sync" },
S = { "<cmd>PackerStatus<cr>", "Status" },
u = { "<cmd>PackerUpdate<cr>", "Update" },
},
q = {
name = "quit",
q = {"<cmd>qall<cr>", "quit"},
},
s = {
name = "+Search",
b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"},
-- c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
c = {"<cmd>:nohl<cr>", "no highlight"},
d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
f = {"<cmd>Fzflua files<cr>", "Find File"},
m = {"<cmd>Telescope marks<cr>", "Marks"},
M = {"<cmd>Telescope man_pages<cr>", "Man Pages"},
r = {"<cmd>FzfLua oldfiles<cr>", "Open Recent File"},
R = {"<cmd>Telescope registers<cr>", "Registers"},
t = {"<cmd>FzfLua live_grep<cr>", "Text"},
["#"] = {"<cmd>FzfLua grep_cword<cr>", "Search word under cursor"},
},
S = {
name = "+Session",
s = {"<cmd>SessionSave<cr>", "Save Session"},
l = {"<cmd>SessionLoad<cr>", "Load Session"},
},
t = {
name = "+Test",
a = {"<cmd>TestSuite -v -cover<cr>", "TestSuite"},
t = {"<cmd>TestNearest -v -cover<cr>", "TestNearest"},
f = {"<cmd>TestFile -v -cover<cr>", "TestFile"},
c = {"<cmd>GoCover<cr>", "go coverage"},
C = {"<cmd>GoCoverClear<cr>", "go coverage clear"},
b = {"<cmd>lua require'dap'.toggle_breakpoint()<cr>", "set break point"},
r = {"<cmd>lua require'dap'.continue()<cr>", "continue"},
},
-- extras
z = {
name = "+Zen",
s = {"<cmd>TZBottom<cr>", "toggle status line"},
t = {"<cmd>TZTop<cr>", "toggle tab bar"},
z = {"<cmd>TZAtaraxis<cr>", "toggle zen"},
}
}
local wk = require("which-key")
wk.register(mappings, opts)