diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 67694e2..c1f092a 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -1,4 +1,4 @@ -local disable_distribution_plugins = function() +local disable_default_plugins = function() vim.g.loaded_gzip = 1 vim.g.loaded_tar = 1 vim.g.loaded_tarPlugin = 1 @@ -24,10 +24,10 @@ local load_core = function() vim.g.global_theme = 'nord' -- Config + vim.g.mapleader = ' ' + disable_default_plugins() require('options') require('colors.' .. vim.g.global_theme).highlight() - disable_distribution_plugins() - vim.g.mapleader = ' ' require('plugins') require('mappings') require('events').load_autocmds() diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 24414e0..8930447 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -111,8 +111,8 @@ local function highlight_editors() -- Statusline hi('StatusLine' , c.cyan, c.grey3, '', '') hi('StatusLineNC' , c.fg , c.grey3, '', '') - -- hi('StatusLineTerm' , c.cyan, c.grey3, '', '') - -- hi('StatusLineTermNC', c.fg , c.grey3, '', '') + hi('StatusLineTerm' , c.cyan, c.grey3, '', '') + hi('StatusLineTermNC', c.fg , c.grey3, '', '') -- Search hi('IncSearch', c.white2, c.dark_blue, 'underline', '') @@ -167,6 +167,10 @@ local function highlight_syntax() vim.cmd('hi! link PreCondit PreProc') vim.cmd('hi! link Variable Identifier') + -- sql + vim.cmd('hi! link sqlKeyword Keyword') + vim.cmd('hi! link sqlSpecial Keyword') + -- Diff hi('DiffAdd' , c.green , c.grey1, '', '') hi('DiffChange', c.yellow, c.grey1, '', '') @@ -284,6 +288,12 @@ local function highlight_plugins() hi('rainbowcol6', c.blue, '', 'bold', '') hi('rainbowcol7', c.purple, '', 'bold', '') + -- hop.nvim + hi('HopNextKey', c.red, '', 'bold', '') + hi('HopNextKey1', c.cyan, '', 'bold', '') + hi('HopNextKey2', c.dark_blue, '', '', '') + hi('HopUnmatched', c.grey3, '', '', '') + -- BufferLine hi('BufferLineIndicatorSelected', c.cyan, '', '', '') hi('BufferLineFill', c.grey1, c.grey1, '', '') @@ -325,29 +335,6 @@ local function highlight_plugins() -- trouble.nvim hi('LspTroubleText', c.blue, '', 'bold', '') - -- lspsaga.nvim - hi('DiagnosticError', c.grey1, '', '', '') - hi('DiagnosticWarning', c.purple, '', '', '') - hi('DiagnosticInformation', c.dark_blue, '', '', '') - hi('DiagnosticHint', c.blue, '', '', '') - hi('DiagnosticTruncateLine', c.fg, '', '', '') - hi('LspFloatWinNormal', c.grey2, '', '', '') - hi('LspFloatWinBorder', c.blue, '', '', '') - hi('LspSagaBorderTitle', c.cyan, '', '', '') - hi('LspSagaHoverBorder', c.dark_blue, '', '', '') - hi('LspSagaRenameBorder', c.green, '', '', '') - hi('LspSagaDefPreviewBorder', c.green, '', '', '') - hi('LspSagaCodeActionBorder', c.teal, '', '', '') - hi('LspSagaFinderSelection', c.green, '', '', '') - hi('LspSagaCodeActionTitle', c.dark_blue, '', '', '') - hi('LspSagaCodeActionContent', c.blue, '', '', '') - hi('LspSagaSignatureHelpBorder', c.yellow, '', '', '') - hi('ReferencesCount', c.blue, '', '', '') - hi('DefinitionCount', c.blue, '', '', '') - hi('DefinitionIcon', c.teal, '', '', '') - hi('ReferencesIcon', c.teal, '', '', '') - hi('TargetWord', c.cyan, '', '', '') - -- Telescope hi('TelescopePromptBorder', c.cyan, '', 'bold', '') hi('TelescopeResultsBorder', c.blue, '', 'bold', '') @@ -376,7 +363,6 @@ function M.highlight() vim.cmd('hi clear') if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end vim.o.background = 'dark' - vim.o.termguicolors = true -- Load highlight groups local async diff --git a/home/.config/nvim/lua/events.lua b/home/.config/nvim/lua/events.lua index 1a475a7..bc1ca0b 100644 --- a/home/.config/nvim/lua/events.lua +++ b/home/.config/nvim/lua/events.lua @@ -50,7 +50,7 @@ function M.load_autocmds() -- Auto-hide numbers, statusline in specific buffers -- {"BufEnter", "term://*", "setlocal norelativenumber nonumber"}, -- {"BufEnter", "term://*", "set laststatus=0"}, - {"BufEnter,BufWinEnter,WinEnter,CmdwinEnter", "*", [[if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif]]} + -- {"BufEnter,BufWinEnter,WinEnter,CmdwinEnter", "*", [[if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif]]} }, wins = { diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 567f6bf..9698004 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -97,6 +97,7 @@ wk.register({ -- ToggleTerm [''] = {':ToggleTerm', 'Toggle terminal'}, + [''] = {':ToggleTerm direction=float', 'Toggle float terminal'}, -- hop.nvim s = {':HopWord', 'Hop to word'}, @@ -182,8 +183,8 @@ wk.register({ n = 'Rename in buffer', o = 'Format buffer', r = 'Remove workspace folder', - s = 'Signature help', w = 'List workspace folders', + x = 'Signature help', f = { name = 'Telescope', a = {':Telescope lsp_code_actions', 'Code actions'}, @@ -198,11 +199,14 @@ wk.register({ S = {':Telescope lsp_workspace_symbols', 'Workspace symbols'} }, g = {':SymbolsOutline', 'Symbol outline'}, - D = {'TroubleToggle lsp_definitions', 'Definition list'}, - E = {'TroubleToggle lsp_document_diagnostics', 'Document diagnostics list'}, - W = {'TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics list'}, - L = {'TroubleToggle loclist', 'Location list items'}, - Q = {'TroubleToggle quickfix', 'Quickfix list'} + t = { + name = 'Trouble', + d = {':TroubleToggle lsp_definitions', 'Definition list'}, + e = {':TroubleToggle lsp_document_diagnostics', 'Document diagnostics list'}, + w = {':TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics list'}, + l = {':TroubleToggle loclist', 'Location list items'}, + q = {':TroubleToggle quickfix', 'Quickfix list'} + } }, n = {':NnnPicker %:p:h', 'File picker'}, diff --git a/home/.config/nvim/lua/modules/blankline.lua b/home/.config/nvim/lua/modules/blankline.lua deleted file mode 100644 index 9c0b52d..0000000 --- a/home/.config/nvim/lua/modules/blankline.lua +++ /dev/null @@ -1,49 +0,0 @@ -local function blankline_options() - vim.g.indent_blankline_char = '│' - -- vim.g.indent_blankline_space_char = '·' - vim.g.indent_blankline_show_first_indent_level = true - vim.g.indent_blankline_filetype_exclude = { - 'startify', - 'dashboard', - 'dotooagenda', - 'log', - 'fugitive', - 'gitcommit', - 'packer', - 'vimwiki', - 'markdown', - 'json', - 'txt', - 'vista', - 'help', - 'todoist', - 'NvimTree', - 'peekaboo', - 'git', - 'TelescopePrompt', - 'undotree', - 'flutterToolsOutline', - '' -- for all buffers without a file type - } - vim.g.indent_blankline_buftype_exclude = {'terminal', 'nofile'} - vim.g.indent_blankline_show_trailing_blankline_indent = false - vim.g.indent_blankline_show_current_context = true - vim.g.indent_blankline_context_patterns = { - 'class', - 'function', - 'method', - 'block', - 'list_literal', - 'selector', - '^if', - '^table', - 'if_statement', - 'while', - 'for' - } - - -- Refresh often, since it is lazy-loaded - -- vim.cmd('autocmd CursorMoved * IndentBlanklineRefresh') -end - -blankline_options() diff --git a/home/.config/nvim/lua/modules/bufferline.lua b/home/.config/nvim/lua/modules/bufferline.lua deleted file mode 100644 index d221650..0000000 --- a/home/.config/nvim/lua/modules/bufferline.lua +++ /dev/null @@ -1,20 +0,0 @@ -return require('bufferline').setup { - options = { - numbers = 'none', - max_name_length = 16, - max_prefix_length = 14, - tab_size = 20, - diagnostics = 'nvim_lsp', - show_close_icon = false, - show_buffer_icons = true, - show_tab_indicators = true, - enforce_regular_tabs = false, - show_buffer_close_icons = true, - always_show_bufferline = true, - offsets = { - {filetype = 'NvimTree', text = 'NvimTree', text_align = 'left'}, - {filetype = 'packer', text = 'Packer', text_align = 'left'} - }, - separator_style = 'thin' - } -} diff --git a/home/.config/nvim/lua/modules/cmdline.lua b/home/.config/nvim/lua/modules/cmdline.lua deleted file mode 100644 index 5aa89d5..0000000 --- a/home/.config/nvim/lua/modules/cmdline.lua +++ /dev/null @@ -1,31 +0,0 @@ -vim.cmd [[ call wilder#setup({'modes': [':', '/', '?']}) ]] - --- Doesn't work yet. Bugs in Neovim (see neovim/neovim#14809 and gelguy/wilder.nvim#53) --- so can't do multi-line config inside vim.cmd [[ ]] with \ -vim.cmd [[ -call wilder#set_option('renderer', wilder#renderer_mux({ - \ ':': wilder#popupmenu_renderer({ - \ 'highlighter': wilder#basic_highlighter(), - \ 'left': wilder#popupmenu_devicons(), - \ 'right': [' ', wilder#popupmenu_scrollbar()] - \ }), - \ '/': wilder#wildmenu_renderer({ - \ 'highlighter': wilder#basic_highlighter(), - \ 'separator': ' · ', - \ 'right': [' ', wilder#wildmenu_index()] - \ }) - \ })) -]] - -vim.cmd [[ -call wilder#set_option('pipeline', [ - \ wilder#branch( - \ wilder#python_file_finder_pipeline({ - \ 'file_command': ['fd', '--type', 'f', '--follow', '--hidden', '--exclude', '.git'], - \ 'dir_command': ['fd', '--type', 'd', '--follow', '--hidden', '--exclude', '.git'] - \ }), - \ wilder#cmdline_pipeline({'language': 'python'}), - \ wilder#python_search_pipeline() - \ ) - \ ]) -]] diff --git a/home/.config/nvim/lua/modules/colorizer.lua b/home/.config/nvim/lua/modules/colorizer.lua deleted file mode 100644 index 88e8ac7..0000000 --- a/home/.config/nvim/lua/modules/colorizer.lua +++ /dev/null @@ -1,13 +0,0 @@ -return require('colorizer').setup( - {'*'}, - { - RGB = true, -- #RGB hex codes - RRGGBB = true, -- #RRGGBB hex codes - names = true, -- "Name" codes like Blue - 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 - mode = 'background' -- Set the display mode. -}) diff --git a/home/.config/nvim/lua/modules/completion.lua b/home/.config/nvim/lua/modules/completion.lua index 284b938..3939ff2 100644 --- a/home/.config/nvim/lua/modules/completion.lua +++ b/home/.config/nvim/lua/modules/completion.lua @@ -1,64 +1,156 @@ -require('compe').setup { - enabled = true, - autocomplete = true, - debug = false, - min_length = 1, - preselect = 'always', - source = { - orgmode = true, - path = true, - buffer = true, - calc = false, - nvim_lsp = true, - nvim_lua = false, - vsnip = false, - luasnip = true, - utilsnips = false, - tags = false, - spell = true +local M = {} + +function M.cmp_conf() + local cmp = require('cmp') + local luasnip = require('luasnip') + + local check_back_space = function() + local col = vim.fn.col '.' - 1 + return col == 0 or vim.fn.getline('.'):sub(col, col):match '%s' ~= nil + end + + local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) + end + + cmp.setup { + formatting = { + format = function(entry, vim_item) + local lspkind_icons = { + Text = '', + Method = '', + Function = '', + Constructor = '', + Field = 'ﰠ', + Variable = '', + Class = 'ﴯ', + Interface = '', + Module = '', + Property = 'ﰠ', + Unit = '塞', + Value = '', + Enum = '', + Keyword = '', + Snippet = '', + Color = '', + File = '', + Reference = '', + Folder = '', + EnumMember = '', + Constant = '', + Struct = 'פּ', + Event = '', + Operator = '', + TypeParameter = '' + } + -- load lspkind icons + vim_item.kind = string.format('%s %s', lspkind_icons[vim_item.kind], vim_item.kind) + + vim_item.menu = ({ + luasnip = '[SNIP]', + path = '[PATH]', + buffer = '[BUF]', + -- calc = '[CALC]', + -- nuspell = '[SPELL]', + spell = '[SPELL]', + emoji = '[EMOJI]', + nvim_lsp = '[LSP]', + latex_symbols = '[TEX]', + tmux = '[TMUX]', + orgmode = '[ORG]' + })[entry.source.name] + + return vim_item + end + }, + mapping = { + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.close(), + -- supertab-like mapping + [''] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(''), 'n') + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys(t('luasnip-expand-or-jump'), '') + elseif check_back_space() then + vim.fn.feedkeys(t(''), 'n') + else + fallback() + end + end, {'i', 's'}), + [''] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(''), 'n') + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(t('luasnip-jump-prev'), '') + else + fallback() + end + end, {'i', 's'}) + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = { + {name = 'luasnip'}, + {name = 'path'}, + {name = 'buffer'}, + -- {name = 'calc'}, + -- {name = 'nuspell'}, + {name = 'spell'}, + {name = 'emoji'}, + {name = 'nvim_lsp'}, + {name = 'latex_symbols'}, + {name = 'tmux'}, + {name = 'orgmode'} + } } -} - --- Use (S-)Tab in completion menu --- See https://github.com/neovim/nvim-lspconfig/wiki/Snippets -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 +function M.autopairs_conf() + require('nvim-autopairs').setup {fast_wrap = {}} + require('nvim-autopairs.completion.cmp').setup({ + map_cr = true, -- map on insert mode + map_complete = true, -- it will auto insert `(` after select function or method item + auto_select = true -- automatically select the first item + }) end -_G.tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t '' - elseif require('luasnip').expand_or_jumpable() then - return t 'luasnip-expand-or-jump' - elseif check_back_space() then - return t '' - else - return vim.fn['compe#complete']() - end -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t '' - elseif require('luasnip').jumpable(-1) then - return t 'luasnip-jump-prev' - else - return t '' - end +function M.snippets_conf() + require('luasnip').config.set_config({ + updateevents = 'TextChanged, TextChangedI', + history = true + }) + + -- Loading vscode-like snippets from 'friendly-snippets' + require('luasnip/loaders/from_vscode').lazy_load() end -vim.api.nvim_set_keymap('i', '', 'v:lua.tab_complete()', {expr = true}) -vim.api.nvim_set_keymap('s', '', 'v:lua.tab_complete()', {expr = true}) -vim.api.nvim_set_keymap('i', '', 'v:lua.s_tab_complete()', {expr = true}) -vim.api.nvim_set_keymap('s', '', 'v:lua.s_tab_complete()', {expr = true}) +function M.coq_conf() + -- To add snippets from lsp servers, change lsp.lua: + ----- + -- local coq = require('coq') + -- lspconf..setup(...) --> lspconf..setup(coq.lsp_ensure_capabilities(...)) + vim.g.coq_settings = { + auto_start = true, + display = { + icons = { + mode = 'none' + } + } + } +end -vim.api.nvim_set_keymap('i', '', 'compe#complete()', {expr = true}) -vim.api.nvim_set_keymap('i', '', 'compe#close(\'\')', {expr = true}) +function M.autotag_conf() + require('nvim-treesitter.configs').setup { + autotag = {enable = true} + } +end + +return M diff --git a/home/.config/nvim/lua/modules/dadbod.lua b/home/.config/nvim/lua/modules/dadbod.lua deleted file mode 100644 index e19f7bf..0000000 --- a/home/.config/nvim/lua/modules/dadbod.lua +++ /dev/null @@ -1,10 +0,0 @@ -local function dadbod_options() - vim.g.db_ui_show_help = 0 - vim.g.db_ui_win_position = 'left' - vim.g.db_ui_use_nerd_fonts = 1 - vim.g.db_ui_winwidth = 30 - vim.g.db_ui_save_location = vim.fn.stdpath('cache') .. '/nvim/db_ui_queries' - -- TODO: vim.g.dbs -end - -dadbod_options() diff --git a/home/.config/nvim/lua/modules/dashboard.lua b/home/.config/nvim/lua/modules/dashboard.lua deleted file mode 100644 index 38765ca..0000000 --- a/home/.config/nvim/lua/modules/dashboard.lua +++ /dev/null @@ -1,33 +0,0 @@ -local function dashboard_options() - -- vim.g.dashboard_disable_at_vimenter = 1 - -- vim.g.dashboard_disable_statusline = 1 - vim.g.dashboard_preview_file_height = 12 - vim.g.dashboard_preview_file_width = 80 - vim.g.dashboard_default_executive = 'telescope' - vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions' - vim.g.dashboard_custom_section = { - a = {description = {' Find File SPC f f'}, command = 'DashboardFindFile'}, - b = {description = {' Recents SPC f o'}, command = 'DashboardFindHistory'}, - c = {description = {' Find Word SPC f g'}, command = 'DashboardFindWord'}, - d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'}, - e = {description = {' Bookmarks SPC f m'}, command = 'DashboardJumpMark'} - } - vim.g.dashboard_custom_header = { - " ", - " ", - " ", - "<-. (`-')_ (`-') _ (`-') _ <-. (`-') ", - " \\( OO) ) ( OO).-/ .-> _(OO ) (_) \\(OO )_ ", - ",--./ ,--/ (,------.(`-')----. ,--.(_/,-.\\ ,-(`-'),--./ ,-.)", - "| \\ | | | .---'( OO).-. '\\ \\ / (_/ | ( OO)| `.' |", - "| . '| |)(| '--. ( _) | | | \\ / / | | )| |'.'| |", - "| |\\ | | .--' \\| |)| |_ \\ /_)(| |_/ | | | |", - "| | \\ | | `---. ' '-' '\\-'\\ / | |'->| | | |", - "`--' `--' `------' `-----' `-' `--' `--' `--'", - } - vim.g.dashboard_custom_footer = { - 'おかえりなさい' - } -end - -dashboard_options() diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua new file mode 100644 index 0000000..95eae59 --- /dev/null +++ b/home/.config/nvim/lua/modules/editor.lua @@ -0,0 +1,132 @@ +local M = {} + +function M.colorizer_conf() + require('colorizer').setup( + {'*'}, + { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = true, -- "Name" codes like Blue + 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 + mode = 'background' -- Set the display mode. + }) +end + +function M.blankline_conf() + vim.g.indent_blankline_char = '│' + -- vim.g.indent_blankline_space_char = '·' + vim.g.indent_blankline_show_first_indent_level = true + vim.g.indent_blankline_filetype_exclude = { + 'startify', + 'dashboard', + 'dotooagenda', + 'log', + 'fugitive', + 'gitcommit', + 'packer', + 'vimwiki', + 'markdown', + 'org', + 'json', + 'txt', + 'vista', + 'help', + 'todoist', + 'NvimTree', + 'peekaboo', + 'git', + 'TelescopePrompt', + 'undotree', + 'flutterToolsOutline', + '' -- for all buffers without a file type + } + vim.g.indent_blankline_buftype_exclude = {'terminal', 'nofile'} + vim.g.indent_blankline_show_trailing_blankline_indent = false + vim.g.indent_blankline_show_current_context = true + vim.g.indent_blankline_context_patterns = { + 'class', + 'function', + 'method', + 'block', + 'list_literal', + 'selector', + '^if', + '^table', + 'if_statement', + 'while', + 'for' + } + + -- Refresh often, since it is lazy-loaded + -- vim.cmd('autocmd CursorMoved * IndentBlanklineRefresh') +end + +function M.treesitter_conf() + vim.api.nvim_command('set foldmethod=expr') + vim.api.nvim_command('set foldexpr=nvim_treesitter#foldexpr()') + + require('nvim-treesitter.configs').setup { + ensure_installed = 'maintained', + highlight = {enable = true}, + textobjects = { + select = { + enable = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner' + } + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']['] = '@function.outer', + [']m'] = '@class.outer' + }, + goto_next_end = { + [']]'] = '@function.outer', + [']M'] = '@class.outer' + }, + goto_previous_start = { + ['[['] = '@function.outer', + ['[m'] = '@class.outer' + }, + goto_previous_end = { + ['[]'] = '@function.outer', + ['[M'] = '@class.outer' + } + } + }, + matchup = {enable = true} + } +end + +function M.rainbow_conf() + require('nvim-treesitter.configs').setup { + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = 1000 + } + } +end + +function M.matchup_conf() + vim.g.matchup_matchparen_offscreen = {method = 'popup'} +end + +function M.hop_conf() + require('hop').setup{keys = 'etovxqpdygfblzhckisuran'} +end + +function M.comment_conf() + require('nvim_comment').setup({comment_empty = false}) +end + +return M diff --git a/home/.config/nvim/lua/modules/gitgutter.lua b/home/.config/nvim/lua/modules/gitgutter.lua deleted file mode 100644 index 55a9f24..0000000 --- a/home/.config/nvim/lua/modules/gitgutter.lua +++ /dev/null @@ -1,42 +0,0 @@ -return require('gitsigns').setup { - signs = { - add = {hl = 'DiffAdd' , text = '', numhl='GitSignsAddNr'}, - change = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'}, - delete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'}, - topdelete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'}, - changedelete = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'} - }, - numhl = true, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - - ['n ]g'] = {expr = true, '&diff ? \']g\' : \'lua require"gitsigns.actions".next_hunk()\''}, - ['n [g'] = {expr = true, '&diff ? \'[g\' : \'lua require"gitsigns.actions".prev_hunk()\''}, - - ['n gs'] = 'lua require"gitsigns".stage_hunk()', - ['v gs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', - ['n gu'] = 'lua require"gitsigns".undo_stage_hunk()', - ['n gr'] = 'lua require"gitsigns".reset_hunk()', - ['v gr'] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', - ['n gR'] = 'lua require"gitsigns".reset_buffer()', - ['n gp'] = 'lua require"gitsigns".preview_hunk()', - ['n gb'] = 'lua require"gitsigns".blame_line(true)' - }, - watch_index = { - interval = 1000, - follow_files = true - }, - current_line_blame = false, - current_line_blame_opts = { - delay = 1000, - virt_text = true, - virt_text_pos = 'eol' - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - word_diff = false, - use_internal_diff = true -- If luajit is present -} diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index daa9a6b..fac90ec 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -1,126 +1,166 @@ -local lspconf = require('lspconfig') +local M = {} -local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') +function M.lsp_conf() + local lspconf = require('lspconfig') - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) + local on_attach = function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + local function buf_set_keymap(...) + vim.api.nvim_buf_set_keymap(bufnr, ...) + end + + local opts = {noremap = true, silent = true} + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', 'lx', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'la', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'lr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'lw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'ld', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'ln', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'le', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'll', 'lua vim.lsp.diagnostic.set_loclist()', opts) + + if client.resolved_capabilities.document_formatting then + buf_set_keymap('n', 'lo', 'lua vim.lsp.buf.formatting()', opts) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap('n', 'lo', 'lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})', opts) + end end - local opts = {noremap = true, silent = true} - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', 'ls', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'la', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'lr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'lw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'ld', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'ln', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'le', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'll', 'lua vim.lsp.diagnostic.set_loclist()', opts) + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true - if client.resolved_capabilities.document_formatting then - buf_set_keymap('n', 'lo', 'lua vim.lsp.buf.formatting()', opts) - elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap('n', 'lo', 'lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})', opts) - end -end + --------------------------- + -- Server configurations -- + --------------------------- + -- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - ---------------------------- --- Server configurations -- ---------------------------- --- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md - --- C/C++ -lspconf.clangd.setup { - on_attach = on_attach, - capabilities = capabilities, - filetypes = {'c', 'cpp'}, - cmd = { - 'clangd', - '-j=2', - '--background-index', - '--clang-tidy', - '--completion-style=detailed', - '--pch-storage=memory', - '--header-insertion=iwyu', - '--header-insertion=decorators' + -- C/C++ + lspconf.clangd.setup { + on_attach = on_attach, + capabilities = capabilities, + filetypes = {'c', 'cpp'}, + cmd = { + 'clangd', + '-j=2', + '--background-index', + '--clang-tidy', + '--completion-style=detailed', + '--pch-storage=memory', + '--header-insertion=iwyu', + '--header-insertion=decorators' + } } -} --- Lua -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, 'lua/?.lua') -table.insert(runtime_path, 'lua/?/init.lua') + -- Lua + local runtime_path = vim.split(package.path, ';') + table.insert(runtime_path, 'lua/?.lua') + table.insert(runtime_path, 'lua/?/init.lua') -lspconf.sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - cmd = { - vim.fn.stdpath('data') .. '/lsp/lua-language-server/bin/Linux/lua-language-server', - '-E', - vim.fn.stdpath('data') .. '/lsp/lua-language-server/main.lua' - }, - settings = { - Lua = { - diagnostics = { - globals = {'vim'} - }, - runtime = { - version = 'LuaJIT', - path = runtime_path - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true), - maxPreload = 100000, - preloadFileSize = 100000 - }, - telemetry = { - enable = false + lspconf.sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + cmd = { + vim.fn.stdpath('data') .. '/lsp/lua-language-server/bin/Linux/lua-language-server', + '-E', + vim.fn.stdpath('data') .. '/lsp/lua-language-server/main.lua' + }, + settings = { + Lua = { + diagnostics = { + globals = {'vim'} + }, + runtime = { + version = 'LuaJIT', + path = runtime_path + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + maxPreload = 100000, + preloadFileSize = 100000 + }, + telemetry = { + enable = false + } } } } -} --- Go -lspconf.gopls.setup { - on_attach = on_attach, - capabilities = capabilities, - cmd = {'gopls', '--remote=auto'}, - init_options = { - usePlaceholders = true, - completeUnimported = true - } -} - --- Others -local servers = { - 'dockerls', - 'bashls', - 'pyright', - 'tsserver', - 'html', - 'jsonls', - 'cmake', - 'rust_analyzer' -} -for _, server in ipairs(servers) do - lspconf[server].setup { + -- Go + lspconf.gopls.setup { on_attach = on_attach, - capabilities = capabilities + capabilities = capabilities, + cmd = {'gopls', '--remote=auto'}, + init_options = { + usePlaceholders = true, + completeUnimported = true + } + } + + -- Others + local servers = { + 'dockerls', + 'bashls', + 'pyright', + 'tsserver', + 'html', + 'jsonls', + 'cmake', + 'sqls', + 'rust_analyzer' + } + for _, server in ipairs(servers) do + lspconf[server].setup { + on_attach = on_attach, + capabilities = capabilities + } + end + + -- Replace the default lsp diagnostic letters with prettier symbols + vim.fn.sign_define('LspDiagnosticsSignError', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignInformation', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''}) +end + +function M.sqls_conf() + require('sqls').setup { + picker = 'telescope' } end --- Replace the default lsp diagnostic letters with prettier symbols -vim.fn.sign_define('LspDiagnosticsSignError', {text = ''}) -vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''}) -vim.fn.sign_define('LspDiagnosticsSignInformation', {text = ''}) -vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''}) +function M.trouble_conf() + require('trouble').setup { + mode = 'lsp_workspace_diagnostics', + fold_open = ' ', + fold_closed = '', + action_keys = { + open_split = {''}, + open_vsplit = {''}, + open_tab = {''} + }, + signs = { + error = '', + warning = '', + hint = '', + information = '', + other = '' + } + } +end + +function M.outline_conf() + vim.g.symbols_outline = { + highlight_hovered_item = false, + show_guides = false + } +end + +return M diff --git a/home/.config/nvim/lua/modules/lsptrouble.lua b/home/.config/nvim/lua/modules/lsptrouble.lua deleted file mode 100644 index 41ce577..0000000 --- a/home/.config/nvim/lua/modules/lsptrouble.lua +++ /dev/null @@ -1,17 +0,0 @@ -return require('trouble').setup { - mode = 'lsp_workspace_diagnostics', - fold_open = ' ', - fold_closed = '', - action_keys = { - open_split = {''}, - open_vsplit = {''}, - open_tab = {''} - }, - signs = { - error = '', - warning = '', - hint = '', - information = '', - other = '' - } -} diff --git a/home/.config/nvim/lua/modules/markdown-preview.lua b/home/.config/nvim/lua/modules/markdown-preview.lua deleted file mode 100644 index 83cc9d7..0000000 --- a/home/.config/nvim/lua/modules/markdown-preview.lua +++ /dev/null @@ -1,12 +0,0 @@ -local function markdownPreview_options() - vim.g.mkdp_refresh_slow = 1 - vim.g.mkdp_filetypes = { - 'markdown', - 'pandoc.markdown', - 'rmd' - } - -- vim.g.mkdp_page_title = '「${name}」' - -- vim.g.mkdp_echo_preview_url = 1 -end - -markdownPreview_options() diff --git a/home/.config/nvim/lua/modules/nvimtree.lua b/home/.config/nvim/lua/modules/nvimtree.lua deleted file mode 100644 index d2c4889..0000000 --- a/home/.config/nvim/lua/modules/nvimtree.lua +++ /dev/null @@ -1,44 +0,0 @@ -local function tree_options() - vim.g.nvim_tree_width = 35 - vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'} - vim.g.nvim_tree_auto_open = 0 - vim.g.nvim_tree_auto_close = 1 - vim.g.nvim_tree_auto_ignore_ft = {'dashboard'} - vim.g.nvim_tree_follow = 1 - vim.g.nvim_tree_indent_markers = 1 - vim.g.nvim_tree_git_hl = 1 - vim.g.nvim_tree_auto_resize = 0 - -- vim.g.nvim_tree_add_trailing = 1 - vim.g.nvim_tree_lsp_diagnostics = 1 - vim.g.nvim_tree_icons = { - default = '', - symlink = '', - git = { - unstaged = "", - staged = "", - unmerged = "", - renamed = "", - untracked = "★", - deleted = "", - ignored = "" - }, - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "" - }, - lsp = { - hint = "", - info = "", - warning = "", - error = "" - } - } -end - -tree_options() diff --git a/home/.config/nvim/lua/modules/org.lua b/home/.config/nvim/lua/modules/org.lua deleted file mode 100644 index 135f24d..0000000 --- a/home/.config/nvim/lua/modules/org.lua +++ /dev/null @@ -1,39 +0,0 @@ -local c = require('colors.' .. vim.g.global_theme).colors - -return require('orgmode').setup({ - -- General settings - org_agenda_files = { - '~/Documents/Org/agenda/agenda.org', - '~/Documents/Org/agenda/archive.org' - }, - org_default_notes_file = '~/Documents/Org/notes.org', - org_todo_keywords = { - 'TODO', 'PROJ', 'LOOP', 'STRT', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', - '[ ]', '[-]', '[X]' , '|', 'OKAY', 'YES', 'NO' - }, - org_todo_keyword_faces = { - TODO = ':foreground ' .. c.green .. ' :weight bold', - PROJ = ':foreground ' .. c.grey_bright .. ' :weight bold :slant italic', - LOOP = ':foreground ' .. c.green .. ' :weight bold :underline on', - STRT = ':foreground ' .. c.blue .. ' :weight bold', - WAIT = ':foreground ' .. c.yellow .. ' :weight bold', - HOLD = ':foreground ' .. c.yellow .. ' :weight bold :slant italic', - IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic', - DONE = ':foreground ' .. c.grey2 .. ' :weight bold', - KILL = ':foreground ' .. c.red .. ' :weight bold', - OKAY = ':foreground ' .. c.grey1 .. ' :weight bold :slant italic', - YES = ':foreground ' .. c.grey1 .. ' :weight bold :underline on', - NO = ':foreground ' .. c.red .. ' :weight bold :underline on' - }, - org_hide_leading_stars = true, - org_highlight_latex_and_related = 'entities', - - -- Agenda settings - org_deadline_warning_days = 7, - org_agenda_span = 'week', - org_agenda_start_on_weekday = 7, -- Start a week in Sunday - org_agenda_min_height = 15, - - -- Tags settings - org_use_tag_inheritance = false -}) diff --git a/home/.config/nvim/lua/modules/picker.lua b/home/.config/nvim/lua/modules/picker.lua deleted file mode 100644 index b879200..0000000 --- a/home/.config/nvim/lua/modules/picker.lua +++ /dev/null @@ -1,13 +0,0 @@ -return require('nnn').setup { - set_default_mappings = false, - session = 'global', - layout = { - window = {width = 0.8, height = 0.8, highlight = 'Debug'}, - }, - command = 'nnn -HUdex', - action = { - [''] = 'tab split', - [''] = 'split', - [''] = 'vsplit' - } -} diff --git a/home/.config/nvim/lua/modules/snippets.lua b/home/.config/nvim/lua/modules/snippets.lua deleted file mode 100644 index bef7bf0..0000000 --- a/home/.config/nvim/lua/modules/snippets.lua +++ /dev/null @@ -1,11 +0,0 @@ -local function luaSnip_setup() - require('luasnip').config.set_config({ - updateevents = 'TextChanged, TextChangedI', - history = true - }) - - -- Loading vscode-like snippets from 'friendly-snippets' - require('luasnip/loaders/from_vscode').lazy_load() -end - -luaSnip_setup() diff --git a/home/.config/nvim/lua/modules/statusline.lua b/home/.config/nvim/lua/modules/statusline.lua deleted file mode 100644 index 3295748..0000000 --- a/home/.config/nvim/lua/modules/statusline.lua +++ /dev/null @@ -1,234 +0,0 @@ -local gl = require('galaxyline') -local gls = gl.section -local condition = require('galaxyline.condition') - -gl.short_line_list = {'NvimTree', 'packer', 'Outline'} - -local colors = require('colors.' .. vim.g.global_theme).colors - -gls.left[1] = { - LeftCorner = { - provider = function() - return '▊ ' - end, - highlight = {colors.blue, colors.grey1} - } -} - -gls.left[2] = { - ViMode = { - provider = function() - local mode_color = { - n = colors.green, -- Normal - no = colors.green, -- N-Pending - i = colors.blue, -- Insert - ic = colors.blue, -- Insert - v = colors.yellow, -- Visual - [''] = colors.yellow, -- V-Block - V = colors.yellow, -- V-Line - c = colors.white2, -- Command - s = colors.purple, -- Select - S = colors.purple, -- S-Line - [''] = colors.purple, -- S-Block - R = colors.red, -- Replace - Rv = colors.red, -- V-Replace - cv = colors.white2, -- Vim-Ex - ce = colors.white2, -- Ex - r = colors.cyan, -- Prompt - rm = colors.cyan, -- More - ['r?'] = colors.cyan, -- Confirm - ['!'] = colors.orange, -- Shell - t = colors.orange -- Terminal - } - vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()]) - return ' ' - end, - highlight = {colors.green, colors.grey1} - } -} - -gls.left[3] = { - FileSize = { - provider = 'FileSize', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1} - } -} - -gls.left[4] ={ - FileIcon = { - provider = 'FileIcon', - condition = condition.buffer_not_empty, - highlight = { - require('galaxyline.provider_fileinfo').get_file_icon_color, - colors.grey1 - } - } -} - -gls.left[5] = { - FileName = { - provider = 'FileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1, 'bold'} - } -} - -gls.left[6] = { - LineInfo = { - provider = 'LineColumn', - highlight = {colors.fg, colors.grey1} - } -} - -gls.left[7] = { - PerCent = { - provider = 'LinePercent', - highlight = {colors.fg, colors.grey1, 'bold'} - } -} - -gls.left[8] = { - DiagnosticError = { - provider = 'DiagnosticError', - icon = '  ', - highlight = {colors.red, colors.grey1} - } -} - -gls.left[9] = { - DiagnosticWarn = { - provider = 'DiagnosticWarn', - icon = '  ', - highlight = {colors.yellow, colors.grey1} - } -} - -gls.left[10] = { - DiagnosticHint = { - provider = 'DiagnosticHint', - icon = '  ', - highlight = {colors.cyan, colors.grey1} - } -} - -gls.left[11] = { - DiagnosticInfo = { - provider = 'DiagnosticInfo', - icon = '  ', - highlight = {colors.blue, colors.grey1} - } -} - -gls.right[1] = { - ShowLspClient = { - provider = 'GetLspClient', - condition = function () - local tbl = {['dashboard'] = true, [''] = true} - if tbl[vim.bo.filetype] then - return false - end - return true - end, - icon = ' LSP:', - highlight = {colors.purple, colors.grey1, 'bold'} - } -} - -gls.right[2] = { - FileEncode = { - provider = 'FileEncode', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.fg, colors.grey1} - } -} - -gls.right[3] = { - FileFormat = { - provider = 'FileFormat', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.fg, colors.grey1} - } -} - -gls.right[4] = { - GitIcon = { - provider = function() return '  ' end, - condition = condition.check_git_workspace, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.green, colors.grey1, 'bold'} - } -} - -gls.right[5] = { - GitBranch = { - provider = 'GitBranch', - condition = condition.check_git_workspace, - highlight = {colors.green, colors.grey1, 'bold'} - } -} - -gls.right[6] = { - GitSeparator = { - provider = function() - return ' ' - end, - highlight = {colors.green, colors.grey1} - } -} - -gls.right[7] = { - DiffAdd = { - provider = 'DiffAdd', - condition = condition.hide_in_width, - icon = ' ', - highlight = {colors.green, colors.grey1} - } -} - -gls.right[8] = { - DiffModified = { - provider = 'DiffModified', - condition = condition.hide_in_width, - icon = '柳', - highlight = {colors.yellow, colors.grey1} - } -} - -gls.right[9] = { - DiffRemove = { - provider = 'DiffRemove', - condition = condition.hide_in_width, - icon = ' ', - highlight = {colors.red, colors.grey1} - } -} - -gls.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.blue, colors.grey1, 'bold'} - } -} - -gls.short_line_left[2] = { - SFileName = { - provider = 'SFileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1, 'bold'} - } -} - -gls.short_line_right[1] = { - BufferIcon = { - provider= 'BufferIcon', - highlight = {colors.fg, colors.grey1} - } -} diff --git a/home/.config/nvim/lua/modules/telescope-nvim.lua b/home/.config/nvim/lua/modules/telescope-nvim.lua deleted file mode 100644 index 4d8b9b1..0000000 --- a/home/.config/nvim/lua/modules/telescope-nvim.lua +++ /dev/null @@ -1,43 +0,0 @@ -local function telescope_setup() - require('telescope').setup { - defaults = { - prompt_prefix = '  ', - selection_caret = ' ', - set_env = {['COLORTERM'] = 'truecolor'}, - layout_strategy = 'horizontal', - layout_config = { - horizontal = { - preview_width = 0.6 - }, - -- prompt_position = 'top', - width = 0.8, - height = 0.8 - }, - file_ignore_patterns = {'.git', '.svn', '.hg', 'node_modules'} - }, - pickers = { - find_files = { - hidden = true, - follow = true - }, - grep_string = { - opts = '--hidden' - } - }, - extensions = { - project = { - base_dirs = {{'~/Code', max_depth = 2}} - }, - fzf = { - fuzzy = true, - override_generic_sorter = false, - override_file_sorter = true, - case_mode = 'smart_case' - } - } - } - require('telescope').load_extension('project') - require('telescope').load_extension('fzf') -end - -telescope_setup() diff --git a/home/.config/nvim/lua/modules/terminal.lua b/home/.config/nvim/lua/modules/terminal.lua deleted file mode 100644 index b3aa046..0000000 --- a/home/.config/nvim/lua/modules/terminal.lua +++ /dev/null @@ -1,13 +0,0 @@ -return require('toggleterm').setup { - shade_terminals = false, - float_opts = { - border = 'curved', - width = 80, - height = 80, - winblend = 3, - highlights = { - border = 'Normal', - background = 'Normal' - } - } -} diff --git a/home/.config/nvim/lua/modules/textobjects.lua b/home/.config/nvim/lua/modules/textobjects.lua deleted file mode 100644 index ba3f468..0000000 --- a/home/.config/nvim/lua/modules/textobjects.lua +++ /dev/null @@ -1,33 +0,0 @@ -return require('nvim-treesitter.configs').setup { - textobjects = { - select = { - enable = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner" - } - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]["] = "@function.outer", - ["]m"] = "@class.outer" - }, - goto_next_end = { - ["]]"] = "@function.outer", - ["]M"] = "@class.outer" - }, - goto_previous_start = { - ["[["] = "@function.outer", - ["[m"] = "@class.outer" - }, - goto_previous_end = { - ["[]"] = "@function.outer", - ["[M"] = "@class.outer" - } - } - } -} diff --git a/home/.config/nvim/lua/modules/tools.lua b/home/.config/nvim/lua/modules/tools.lua new file mode 100644 index 0000000..5efcc48 --- /dev/null +++ b/home/.config/nvim/lua/modules/tools.lua @@ -0,0 +1,217 @@ +local M = {} + +function M.telescope_conf() + require('telescope').setup { + defaults = { + prompt_prefix = '  ', + selection_caret = ' ', + set_env = {['COLORTERM'] = 'truecolor'}, + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + preview_width = 0.6 + }, + -- prompt_position = 'top', + width = 0.8, + height = 0.8 + }, + file_ignore_patterns = {'.git', '.svn', '.hg', 'node_modules'} + }, + pickers = { + find_files = { + hidden = true, + follow = true + }, + grep_string = { + opts = '--hidden' + } + }, + extensions = { + project = { + base_dirs = {{'~/Code', max_depth = 2}} + }, + fzf = { + fuzzy = true, + override_generic_sorter = false, + override_file_sorter = true, + case_mode = 'smart_case' + } + } + } + require('telescope').load_extension('project') + require('telescope').load_extension('fzf') +end + +function M.nnn_conf() + require('nnn').setup { + set_default_mappings = false, + session = 'global', + layout = { + window = {width = 0.8, height = 0.8, highlight = 'Debug'}, + }, + command = 'nnn -HUdex', + action = { + [''] = 'tab split', + [''] = 'split', + [''] = 'vsplit' + } + } +end + +function M.octo_conf() + require('octo').setup() +end + +function M.neogit_conf() + require('neogit').setup { + integrations = { + diffview = true + } + } +end + +function M.markdown_preview_conf() + vim.g.mkdp_refresh_slow = 1 + vim.g.mkdp_filetypes = { + 'markdown', + 'pandoc.markdown', + 'rmd' + } + -- vim.g.mkdp_page_title = '「${name}」' + -- vim.g.mkdp_echo_preview_url = 1 +end + +function M.zenmode_conf() + require('zen-mode').setup { + window = { + options = { + signcolumn = 'no', + number = false, + relativenumber = false, + cursorline = false, + cursorcolumn = false, + foldcolumn = '0' + } + }, + on_open = function() + vim.cmd('TSContextDisable') + vim.cmd('IndentBlanklineDisable') + end, + on_close = function() + vim.cmd('TSContextEnable') + -- vim.cmd('IndentBlanklineEnable') + end + } +end + +function M.orgmode_conf() + local c = require('colors.' .. vim.g.global_theme).colors + + require('orgmode').setup({ + -- General settings + org_agenda_files = {'~/Documents/Org/agenda/*'}, + org_default_notes_file = '~/Documents/Org/notes.org', + org_todo_keywords = { + 'TODO', 'PROJ', 'LOOP', 'STRT', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', + '[ ]', '[-]', '[X]' , '|', 'OKAY', 'YES', 'NO' + }, + org_todo_keyword_faces = { + TODO = ':foreground ' .. c.green .. ' :weight bold', + PROJ = ':foreground ' .. c.grey_bright .. ' :weight bold :slant italic', + LOOP = ':foreground ' .. c.green .. ' :weight bold :underline on', + STRT = ':foreground ' .. c.blue .. ' :weight bold', + WAIT = ':foreground ' .. c.yellow .. ' :weight bold', + HOLD = ':foreground ' .. c.yellow .. ' :weight bold :slant italic', + IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic', + DONE = ':foreground ' .. c.grey2 .. ' :weight bold', + KILL = ':foreground ' .. c.red .. ' :weight bold', + OKAY = ':foreground ' .. c.grey1 .. ' :weight bold :slant italic', + YES = ':foreground ' .. c.grey1 .. ' :weight bold :underline on', + NO = ':foreground ' .. c.red .. ' :weight bold :underline on' + }, + org_hide_leading_stars = true, + org_highlight_latex_and_related = 'entities', + + -- Agenda settings + org_deadline_warning_days = 7, + org_agenda_span = 'week', + org_agenda_start_on_weekday = 7, -- Start a week in Sunday + org_agenda_min_height = 15, + + -- Tags settings + org_use_tag_inheritance = false + }) +end + +function M.translate_conf() + vim.g.trans_join_lines = 1 + vim.g.trans_win_height = 15 + vim.g.trans_default_direction = ':ja' + vim.g.trans_directions_list = { + {'', 'en'}, + {'', 'ja'}, + {'', 'de'}, + {'', 'ru'}, + {'', 'fr'}, + {'', 'nl'}, + {'', 'es'}, + {'', 'zh-CN'}, + {'', 'zh-TW'} + } +end + +function M.toggleterm_conf() + require('toggleterm').setup { + shade_terminals = false, + float_opts = { + border = 'curved', + -- width = 80, + -- height = 80, + winblend = 3, + highlights = { + border = 'Normal', + background = 'Normal' + } + } + } +end + +function M.wilder_conf() + vim.cmd [[ call wilder#setup({'modes': [':', '/', '?']}) ]] + + -- Doesn't work yet. Bugs in Neovim (see neovim/neovim#14809 and gelguy/wilder.nvim#53) + -- so can't do multi-line config inside vim.cmd [[ ]] with \ +-- vim.cmd [[ +-- call wilder#set_option('renderer', wilder#renderer_mux({ +-- \ ':': wilder#popupmenu_renderer({ +-- \ 'highlighter': wilder#basic_highlighter(), +-- \ 'left': wilder#popupmenu_devicons(), +-- \ 'right': [' ', wilder#popupmenu_scrollbar()] +-- \ }), +-- \ '/': wilder#wildmenu_renderer({ +-- \ 'highlighter': wilder#basic_highlighter(), +-- \ 'separator': ' · ', +-- \ 'right': [' ', wilder#wildmenu_index()] +-- \ }) +-- \ })) +-- ]] + +-- vim.cmd [[ +-- call wilder#set_option('pipeline', [ +-- \ wilder#branch( +-- \ wilder#python_file_finder_pipeline({ +-- \ 'file_command': ['fd', '--type', 'f', '--follow', '--hidden', '--exclude', '.git'], +-- \ 'dir_command': ['fd', '--type', 'd', '--follow', '--hidden', '--exclude', '.git'] +-- \ }), +-- \ wilder#cmdline_pipeline({'language': 'python'}), +-- \ wilder#python_search_pipeline() +-- \ ) +-- \ ]) +-- ]] +end + +function M.neoscroll_conf() + require('neoscroll').setup() +end + +return M diff --git a/home/.config/nvim/lua/modules/translate-shell.lua b/home/.config/nvim/lua/modules/translate-shell.lua deleted file mode 100644 index 8142eb5..0000000 --- a/home/.config/nvim/lua/modules/translate-shell.lua +++ /dev/null @@ -1,18 +0,0 @@ -local function translate_options() - vim.g.trans_join_lines = 1 - vim.g.trans_win_height = 15 - vim.g.trans_default_direction = ':ja' - vim.g.trans_directions_list = { - {'', 'en'}, - {'', 'ja'}, - {'', 'de'}, - {'', 'ru'}, - {'', 'fr'}, - {'', 'nl'}, - {'', 'es'}, - {'', 'zh-CN'}, - {'', 'zh-TW'} - } -end - -translate_options() diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua new file mode 100644 index 0000000..8379c17 --- /dev/null +++ b/home/.config/nvim/lua/modules/ui.lua @@ -0,0 +1,401 @@ +local M = {} + +function M.dashboard_conf() + -- vim.g.dashboard_disable_at_vimenter = 1 + -- vim.g.dashboard_disable_statusline = 1 + vim.g.dashboard_preview_file_height = 12 + vim.g.dashboard_preview_file_width = 80 + vim.g.dashboard_default_executive = 'telescope' + vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions' + vim.g.dashboard_custom_section = { + a = {description = {' Find File SPC f f'}, command = 'DashboardFindFile'}, + b = {description = {' Recents SPC f o'}, command = 'DashboardFindHistory'}, + c = {description = {' Find Word SPC f g'}, command = 'DashboardFindWord'}, + d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'}, + e = {description = {' Bookmarks SPC f m'}, command = 'DashboardJumpMark'} + } + vim.g.dashboard_custom_header = { + " ", + " ", + " ", + "<-. (`-')_ (`-') _ (`-') _ <-. (`-') ", + " \\( OO) ) ( OO).-/ .-> _(OO ) (_) \\(OO )_ ", + ",--./ ,--/ (,------.(`-')----. ,--.(_/,-.\\ ,-(`-'),--./ ,-.)", + "| \\ | | | .---'( OO).-. '\\ \\ / (_/ | ( OO)| `.' |", + "| . '| |)(| '--. ( _) | | | \\ / / | | )| |'.'| |", + "| |\\ | | .--' \\| |)| |_ \\ /_)(| |_/ | | | |", + "| | \\ | | `---. ' '-' '\\-'\\ / | |'->| | | |", + "`--' `--' `------' `-----' `-' `--' `--' `--'", + } + vim.g.dashboard_custom_footer = { + 'おかえりなさい' + } +end + +function M.statusline_conf() + local gl = require('galaxyline') + local gls = gl.section + local condition = require('galaxyline.condition') + local colors = require('colors.' .. vim.g.global_theme).colors + + gl.short_line_list = {'NvimTree', 'packer', 'Outline'} + + gls.left[1] = { + LeftCorner = { + provider = function() + return '▊ ' + end, + highlight = {colors.blue, colors.grey1} + } + } + + gls.left[2] = { + ViMode = { + provider = function() + local mode_color = { + n = colors.green, -- Normal + no = colors.green, -- N-Pending + i = colors.blue, -- Insert + ic = colors.blue, -- Insert + v = colors.yellow, -- Visual + [''] = colors.yellow, -- V-Block + V = colors.yellow, -- V-Line + c = colors.white2, -- Command + s = colors.purple, -- Select + S = colors.purple, -- S-Line + [''] = colors.purple, -- S-Block + R = colors.red, -- Replace + Rv = colors.red, -- V-Replace + cv = colors.white2, -- Vim-Ex + ce = colors.white2, -- Ex + r = colors.cyan, -- Prompt + rm = colors.cyan, -- More + ['r?'] = colors.cyan, -- Confirm + ['!'] = colors.orange, -- Shell + t = colors.orange -- Terminal + } + vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()]) + return ' ' + end, + highlight = {colors.green, colors.grey1} + } + } + + gls.left[3] = { + FileSize = { + provider = 'FileSize', + condition = condition.buffer_not_empty, + highlight = {colors.fg, colors.grey1} + } + } + + gls.left[4] ={ + FileIcon = { + provider = 'FileIcon', + condition = condition.buffer_not_empty, + highlight = { + require('galaxyline.provider_fileinfo').get_file_icon_color, + colors.grey1 + } + } + } + + gls.left[5] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty, + highlight = {colors.fg, colors.grey1, 'bold'} + } + } + + gls.left[6] = { + LineInfo = { + provider = 'LineColumn', + highlight = {colors.fg, colors.grey1} + } + } + + gls.left[7] = { + PerCent = { + provider = 'LinePercent', + highlight = {colors.fg, colors.grey1, 'bold'} + } + } + + gls.left[8] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = {colors.red, colors.grey1} + } + } + + gls.left[9] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = {colors.yellow, colors.grey1} + } + } + + gls.left[10] = { + DiagnosticHint = { + provider = 'DiagnosticHint', + icon = '  ', + highlight = {colors.cyan, colors.grey1} + } + } + + gls.left[11] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + icon = '  ', + highlight = {colors.blue, colors.grey1} + } + } + + gls.right[1] = { + ShowLspClient = { + provider = 'GetLspClient', + condition = function () + local tbl = {['dashboard'] = true, [''] = true} + if tbl[vim.bo.filetype] then + return false + end + return true + end, + icon = ' LSP:', + highlight = {colors.purple, colors.grey1, 'bold'} + } + } + + gls.right[2] = { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.grey1}, + highlight = {colors.fg, colors.grey1} + } + } + + gls.right[3] = { + FileFormat = { + provider = 'FileFormat', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.grey1}, + highlight = {colors.fg, colors.grey1} + } + } + + gls.right[4] = { + GitIcon = { + provider = function() return '  ' end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE', colors.grey1}, + highlight = {colors.green, colors.grey1, 'bold'} + } + } + + gls.right[5] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + highlight = {colors.green, colors.grey1, 'bold'} + } + } + + gls.right[6] = { + GitSeparator = { + provider = function() + return ' ' + end, + highlight = {colors.green, colors.grey1} + } + } + + gls.right[7] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = ' ', + highlight = {colors.green, colors.grey1} + } + } + + gls.right[8] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = '柳', + highlight = {colors.yellow, colors.grey1} + } + } + + gls.right[9] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = ' ', + highlight = {colors.red, colors.grey1} + } + } + + gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {'NONE', colors.grey1}, + highlight = {colors.blue, colors.grey1, 'bold'} + } + } + + gls.short_line_left[2] = { + SFileName = { + provider = 'SFileName', + condition = condition.buffer_not_empty, + highlight = {colors.fg, colors.grey1, 'bold'} + } + } + + gls.short_line_right[1] = { + BufferIcon = { + provider= 'BufferIcon', + highlight = {colors.fg, colors.grey1} + } + } +end + +function M.bufferline_conf() + require('bufferline').setup { + options = { + numbers = 'none', + max_name_length = 16, + max_prefix_length = 14, + tab_size = 20, + diagnostics = 'nvim_lsp', + show_close_icon = false, + show_buffer_icons = true, + show_tab_indicators = true, + enforce_regular_tabs = false, + show_buffer_close_icons = true, + always_show_bufferline = true, + offsets = { + {filetype = 'NvimTree', text = 'NvimTree', text_align = 'left'}, + {filetype = 'packer', text = 'Packer', text_align = 'left'} + }, + separator_style = 'thin' + } + } +end + +function M.nvimtree_conf() + vim.g.nvim_tree_width = 35 + vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'} + vim.g.nvim_tree_auto_open = 0 + vim.g.nvim_tree_auto_close = 1 + vim.g.nvim_tree_auto_ignore_ft = {'dashboard'} + vim.g.nvim_tree_follow = 1 + vim.g.nvim_tree_indent_markers = 1 + vim.g.nvim_tree_git_hl = 1 + vim.g.nvim_tree_auto_resize = 0 + -- vim.g.nvim_tree_add_trailing = 1 + vim.g.nvim_tree_lsp_diagnostics = 1 + vim.g.nvim_tree_icons = { + default = '', + symlink = '', + git = { + unstaged = '', + staged = '', + unmerged = '', + renamed = '', + untracked = '★', + deleted = '', + ignored = '' + }, + folder = { + arrow_open = '', + arrow_closed = '', + default = '', + open = '', + empty = '', + empty_open = '', + symlink = '', + symlink_open = '' + }, + lsp = { + hint = '', + info = '', + warning = '', + error = '' + } + } +end + +function M.whichkey_conf() + require('which-key').setup { + plugins = { + spelling = { + enabled = true, + suggestions = 30 + } + }, + icons = { + breadcrumb = '»', + separator = 'ﰲ', + group = '+' + }, + layout = { + align = 'center' + } + } +end + +function M.gitsigns_conf() + require('gitsigns').setup { + signs = { + add = {hl = 'DiffAdd' , text = '', numhl='GitSignsAddNr'}, + change = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'}, + delete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'}, + topdelete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'}, + changedelete = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'} + }, + numhl = true, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true, + + ['n ]g'] = {expr = true, '&diff ? \']g\' : \'lua require"gitsigns.actions".next_hunk()\''}, + ['n [g'] = {expr = true, '&diff ? \'[g\' : \'lua require"gitsigns.actions".prev_hunk()\''}, + + ['n gs'] = 'lua require"gitsigns".stage_hunk()', + ['v gs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n gu'] = 'lua require"gitsigns".undo_stage_hunk()', + ['n gr'] = 'lua require"gitsigns".reset_hunk()', + ['v gr'] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n gR'] = 'lua require"gitsigns".reset_buffer()', + ['n gp'] = 'lua require"gitsigns".preview_hunk()', + ['n gb'] = 'lua require"gitsigns".blame_line(true)' + }, + watch_index = { + interval = 1000, + follow_files = true + }, + current_line_blame = false, + current_line_blame_opts = { + delay = 1000, + virt_text = true, + virt_text_pos = 'eol' + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + word_diff = false, + use_internal_diff = true -- If luajit is present + } +end + +return M diff --git a/home/.config/nvim/lua/modules/whichkey.lua b/home/.config/nvim/lua/modules/whichkey.lua deleted file mode 100644 index 7c47e71..0000000 --- a/home/.config/nvim/lua/modules/whichkey.lua +++ /dev/null @@ -1,16 +0,0 @@ -return require('which-key').setup { - plugins = { - spelling = { - enabled = true, - suggestions = 30 - } - }, - icons = { - breadcrumb = "»", - separator = "ﰲ", - group = "+" - }, - layout = { - align = 'center' - } -} diff --git a/home/.config/nvim/lua/modules/zen.lua b/home/.config/nvim/lua/modules/zen.lua deleted file mode 100644 index 549f4e9..0000000 --- a/home/.config/nvim/lua/modules/zen.lua +++ /dev/null @@ -1,20 +0,0 @@ -return require('zen-mode').setup { - window = { - options = { - signcolumn = 'no', - number = false, - relativenumber = false, - cursorline = false, - cursorcolumn = false, - foldcolumn = '0' - } - }, - on_open = function(win) - vim.cmd('TSContextDisable') - vim.cmd('IndentBlanklineDisable') - end, - on_close = function() - vim.cmd('TSContextEnable') - -- vim.cmd('IndentBlanklineEnable') - end, -} diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 615e6dd..920b863 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -1,11 +1,8 @@ local opt = vim.opt local function load_options() - vim.cmd('filetype indent plugin on') - vim.cmd('syntax on') - -- vim.cmd('set iskeyword+=-') - -- General settings + opt.termguicolors = true opt.mouse = 'nv' opt.errorbells = false opt.visualbell = false diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 9e24313..4bb1fa7 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -16,6 +16,7 @@ return require('packer').startup( -------- -- UI -- -------- + local ui = require('modules.ui') use { 'glepnir/dashboard-nvim', cmd = { @@ -28,57 +29,44 @@ return require('packer').startup( 'SessionLoad', 'SessionSave' }, - setup = function() - require('modules.dashboard') - end + setup = ui.dashboard_conf } use { -- TODO: consider moving to felline.nvim 'glepnir/galaxyline.nvim', branch = 'main', requires = 'kyazdani42/nvim-web-devicons', - config = function() - require('modules.statusline') - end + config = ui.statusline_conf } use { 'akinsho/nvim-bufferline.lua', event = 'BufRead', - config = function() - require('modules.bufferline') - end + config = ui.bufferline_conf } use { 'kyazdani42/nvim-tree.lua', cmd = 'NvimTreeToggle', - setup = function() - require('modules.nvimtree') - end + setup = ui.nvimtree_conf } use { 'folke/which-key.nvim', - config = function() - require('modules.whichkey') - end + config = ui.whichkey_conf } - - ------------------ - -- Highlighting -- - ------------------ use { 'lewis6991/gitsigns.nvim', event = {'BufRead', 'BufNewFile'}, wants = 'plenary.nvim', requires = {{'nvim-lua/plenary.nvim', opt = true}}, - config = function() - require('modules.gitgutter') - end + config = ui.gitsigns_conf } + + ------------ + -- Editor -- + ------------ + local editor = require('modules.editor') use { 'norcalli/nvim-colorizer.lua', cmd = 'ColorizerToggle', - config = function() - require('modules.colorizer') - end + config = editor.colorizer_conf } use { 'RRethy/vim-illuminate', @@ -87,33 +75,19 @@ return require('packer').startup( use { 'lukas-reineke/indent-blankline.nvim', event = 'BufRead', - config = function() - require('modules.blankline') - end + config = editor.blankline_conf } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', event = 'BufRead', - config = function() - require('nvim-treesitter.configs').setup { - ensure_installed = 'maintained', - highlight = {enable = true} - } - end + config = editor.treesitter_conf } use { 'p00f/nvim-ts-rainbow', after = 'nvim-treesitter', - config = function() - require('nvim-treesitter.configs').setup { - rainbow = { - enable = true, - extended_mode = true, - max_file_lines = 1000 - } - } - end + -- Putting config into `treesitter_conf` doesn't work for some reason + config = editor.rainbow_conf } use { 'romgrk/nvim-treesitter-context', @@ -121,47 +95,51 @@ return require('packer').startup( } use { 'nvim-treesitter/nvim-treesitter-textobjects', - after = 'nvim-treesitter', - config = function() - require('modules.textobjects') - end + after = 'nvim-treesitter' } use { 'andymass/vim-matchup', after = 'nvim-treesitter', - config = function() - vim.g.matchup_matchparen_offscreen = {method = 'popup'} - require('nvim-treesitter.configs').setup { - matchup = {enable = true} - } - end + config = editor.matchup_conf + } + use { + 'machakann/vim-sandwich', + keys = {'sa', 'sd', 'sr'} + } + use { + 'phaazon/hop.nvim', + cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'}, + config = editor.hop_conf + } + use { + 'junegunn/vim-easy-align', + cmd = 'EasyAlign' + } + use { + 'terrortylor/nvim-comment', + keys = 'gc', + config = editor.comment_conf } --------- -- LSP -- --------- + local lsp = require('modules.lsp') use { 'neovim/nvim-lspconfig', event = 'BufReadPre', - config = function() - require('modules.lsp') - end + config = lsp.lsp_conf + } + use { + 'nanotee/sqls.nvim', + ft = {'sql', 'mysql', 'plsql'}, + wants = 'nvim-lspconfig', + config = lsp.sqls_conf } use { 'ray-x/lsp_signature.nvim', after = 'nvim-lspconfig' } - use { - 'glepnir/lspsaga.nvim', - after = 'nvim-lspconfig' - } - use { - 'onsails/lspkind-nvim', - event = 'InsertEnter', - config = function() - require('lspkind').init({with_text = false}) - end - } use { 'ahmedkhalf/lsp-rooter.nvim', after = 'nvim-lspconfig' @@ -169,38 +147,78 @@ return require('packer').startup( use { 'folke/trouble.nvim', cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'}, - config = function() - require('modules.lsptrouble') - end + config = lsp.trouble_conf } use { 'simrat39/symbols-outline.nvim', cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'}, - setup = function() - vim.g.symbols_outline = { - highlight_hovered_item = false, - show_guides = false - } - end - } - use { -- TODO: replace with nvim-cmp - 'hrsh7th/nvim-compe', - event = 'InsertEnter', - config = function() - require('modules.completion') - end - } - use { -- TODO: lazy-loaded + work with autopairs - 'L3MON4D3/LuaSnip', - requires = 'rafamadriz/friendly-snippets', - config = function() - require('modules.snippets') - end + setup = lsp.outline_conf } - --------------- - -- Utilities -- - --------------- + ---------------- + -- Completion -- + ---------------- + local completion = require('modules.completion') + use { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + wants = {'LuaSnip'}, + requires = { + { + 'L3MON4D3/LuaSnip', + wants = 'friendly-snippets', + requires = {{'rafamadriz/friendly-snippets', opt = true}}, + config = completion.snippets_conf, + opt = true + }, + {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp', opt = true}, + {'hrsh7th/cmp-path', after = 'nvim-cmp', opt = true}, + {'hrsh7th/cmp-buffer', after = 'nvim-cmp', opt = true}, + -- {'hrsh7th/cmp-calc', after = 'nvim-cmp', opt = true}, + -- {'f3fora/cmp-nuspell', after = 'nvim-cmp', rocks={'lua-nuspell'}, opt = true}, + {'f3fora/cmp-spell', after = 'nvim-cmp', opt = true}, + {'hrsh7th/cmp-emoji', after = 'nvim-cmp', opt = true}, + {'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp', opt = true}, + {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp', opt = true}, + {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp', opt = true} + }, + config = completion.cmp_conf + } + use { + 'windwp/nvim-autopairs', + after = 'nvim-cmp', + config = completion.autopairs_conf + } + -- use { + -- 'ms-jpq/coq_nvim', + -- branch = 'coq', + -- event = 'InsertEnter', + -- run = ':COQdeps', + -- wants = 'coq.artifacts', + -- requires = {{'ms-jpq/coq.artifacts', branch = 'artifacts', opt = true}}, + -- setup = completion.coq_conf + -- } + use { + 'windwp/nvim-ts-autotag', + ft = { + 'html', + 'xml', + 'javascript', + 'javascriptreact', + 'typescript', + 'typescriptreact', + 'vue', + 'svelte', + 'php' + }, + wants = 'nvim-treesitter', + config = completion.autotag_conf + } + + ----------- + -- Tools -- + ----------- + local tools = require('modules.tools') use { 'nvim-telescope/telescope.nvim', cmd = 'Telescope', @@ -218,24 +236,18 @@ return require('packer').startup( {'nvim-telescope/telescope-project.nvim', opt = true}, {'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true} }, - config = function() - require('modules.telescope-nvim') - end + config = tools.telescope_conf } use { -- Telescope file browser doesn't support dotfiles 'mcchrish/nnn.vim', cmd = 'NnnPicker', - config = function() - require('modules.picker') - end + config = tools.nnn_conf } use { -- TODO: colors + config 'pwntester/octo.nvim', cmd = 'Octo', wants = 'telescope.nvim', - config = function() - require('octo').setup() - end + config = tools.octo_conf } use { 'TimUntersberger/neogit', @@ -256,37 +268,13 @@ return require('packer').startup( opt = true } }, - config = function() - require('neogit').setup { - integrations = { - diffview = true - } - } - end - } - use { - 'kristijanhusak/vim-dadbod-ui', - cmd = {'DBUIToggle', 'DBUIAddConnection', 'DBUI', 'DBUIFindBuffer', 'DBUIRenameBuffer'}, - wants = 'vim-dadbod', - requires = {{'tpope/vim-dadbod', opt = true}}, - config = function() - require('modules.dadbod') - end - } - use { - 'kristijanhusak/vim-dadbod-completion', - after = 'vim-dadbod-ui', - config = function() - vim.g.compe.source.vim_dadbod_completion = true - end + config = tools.neogit_conf } use { 'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', ft = {'markdown', 'pandoc.markdown', 'rmd'}, - config = function() - require('modules.markdown-preview') - end + config = tools.markdown_preview_conf } use { 'turbio/bracey.vim', @@ -298,45 +286,33 @@ return require('packer').startup( cmd = 'ZenMode', wants = 'twilight.nvim', requires = {{'folke/twilight.nvim', opt = true}}, - config = function() - require('modules.zen') - end + config = tools.zenmode_conf } - use { -- shouldn't be lazy-loaded (otherwise bindings don't work) + use { -- shouldn't be lazy-loaded (global bindings don't work) 'kristijanhusak/orgmode.nvim', - ft = 'org', - config = function() - require('modules.org') - end + ft = {'org'}, + config = tools.orgmode_conf } use { 'echuraev/translate-shell.vim', cmd = {'Trans', 'TransSelectDirection'}, - config = function() - require('modules.translate-shell') - end + config = tools.translate_conf } use { 'akinsho/nvim-toggleterm.lua', cmd = 'ToggleTerm', - config = function() - require('modules.terminal') - end + config = tools.toggleterm_conf } -- use { -- 'gelguy/wilder.nvim', -- run = ':UpdateRemotePlugins', -- event = 'CmdlineEnter', - -- config = function() - -- require('modules.cmdline') - -- end + -- config = tools.wilder_conf -- } use { 'karb94/neoscroll.nvim', event = 'WinScrolled', - config = function() - require('neoscroll').setup() - end + config = tools.neoscroll_conf } use { -- TODO: colors 'michaelb/sniprun', @@ -349,63 +325,7 @@ return require('packer').startup( } use {'tweekmonster/startuptime.vim', cmd = 'StartupTime'} -- Just for benchmarking - ------------ - -- Editor -- - ------------ - use { - 'windwp/nvim-autopairs', - event = 'InsertCharPre', - config = function() - require('nvim-autopairs').setup() - require('nvim-autopairs.completion.compe').setup({ - map_cr = true, - map_complete = true - }) - end - } - use { - 'machakann/vim-sandwich', - keys = {'sa', 'sd', 'sr'} - } - use { - 'phaazon/hop.nvim', - cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'}, - config = function() - require('hop').setup{keys = 'etovxqpdygfblzhckisuran'} - end - } - use { - 'junegunn/vim-easy-align', - cmd = 'EasyAlign' - } - use { - 'terrortylor/nvim-comment', - keys = 'gc', - config = function() - require('nvim_comment').setup({comment_empty = false}) - end - } - use { - 'windwp/nvim-ts-autotag', - ft = { - 'html', - 'xml', - 'javascript', - 'javascriptreact', - 'typescript', - 'typescriptreact', - 'vue', - 'svelte', - 'php' - }, - wants = 'nvim-treesitter', - config = function() - require('nvim-treesitter.configs').setup { - autotag = {enable = true} - } - end - } - - -- TODO: nvim-lint, rest.nvim, sqls.nvim, nvim-spectre, nvim-dap-ui, dial.nvim, asynctasks.nvim + -- TODO: nvim-lint, rest.nvim, parinfer.nvim, editorconfig.nvim, conjure, + -- nvim-spectre, nvim-dap-ui, dial.nvim, asynctasks.nvim, hotpot.nvim end )