From bc7bdb2bdcf4b19d568a9b901ddc531f494148a1 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Sat, 10 Jul 2021 19:40:43 +0300 Subject: [PATCH] neovim: almost done --- home/.config/nvim/init.lua | 8 +- home/.config/nvim/lua/colors/nord.lua | 218 ++++++++++-------- home/.config/nvim/lua/events.lua | 18 +- home/.config/nvim/lua/mappings.lua | 152 ++++++++++-- home/.config/nvim/lua/modules/blankline.lua | 4 + home/.config/nvim/lua/modules/colorizer.lua | 5 +- home/.config/nvim/lua/modules/completion.lua | 17 ++ home/.config/nvim/lua/modules/dadbod.lua | 10 + home/.config/nvim/lua/modules/dashboard.lua | 8 +- .../nvim/lua/modules/markdown-preview.lua | 12 + home/.config/nvim/lua/modules/nvimtree.lua | 10 +- home/.config/nvim/lua/modules/snippets.lua | 11 + .../nvim/lua/modules/telescope-nvim.lua | 40 ++++ home/.config/nvim/lua/modules/terminal.lua | 1 - home/.config/nvim/lua/modules/ts-rainbow.lua | 7 - home/.config/nvim/lua/options.lua | 4 +- home/.config/nvim/lua/plugins.lua | 181 ++++++++++++--- home/.config/ripgrep/config | 2 + 18 files changed, 522 insertions(+), 186 deletions(-) create mode 100644 home/.config/nvim/lua/modules/completion.lua create mode 100644 home/.config/nvim/lua/modules/dadbod.lua create mode 100644 home/.config/nvim/lua/modules/markdown-preview.lua create mode 100644 home/.config/nvim/lua/modules/snippets.lua create mode 100644 home/.config/nvim/lua/modules/telescope-nvim.lua delete mode 100644 home/.config/nvim/lua/modules/ts-rainbow.lua diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 1be0f80..14b8744 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -19,12 +19,6 @@ local disable_distribution_plugins = function() vim.g.loaded_netrwFileHandlers = 1 end -local leader_map = function() - vim.g.mapleader = ' ' - vim.api.nvim_set_keymap('n',' ','',{noremap = true}) - vim.api.nvim_set_keymap('x',' ','',{noremap = true}) -end - local load_core = function() -- Global theme vim.g.global_theme = 'nord' @@ -33,7 +27,7 @@ local load_core = function() require('options') require('colors.' .. vim.g.global_theme).highlight() disable_distribution_plugins() - leader_map() + 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 0f87e2e..f67c2a4 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -1,15 +1,7 @@ +-- Credit: https://github.com/shaunsingh/nord.nvim + local M = {} -local function hi(group, guifg, guibg, attr, guisp) - local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE' - local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE' - local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE' - local sp = guisp ~= '' and 'guisp=' .. guisp or '' - - local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp - vim.cmd(hl) -end - M.colors = { black = '#2E3440', grey1 = '#3B4252', @@ -33,16 +25,38 @@ M.colors = { local c = M.colors -function M.highlight() - -- Reset everything - vim.cmd('hi clear') - if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end - vim.o.background = 'dark' - vim.o.termguicolors = true +local function hi(group, guifg, guibg, attr, guisp) + local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE' + local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE' + local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE' + local sp = guisp ~= '' and 'guisp=' .. guisp or '' - ------------------- - -- UI components -- - ------------------- + local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp + vim.cmd(hl) +end + +-- Set terminal colors +local function set_vim_termcolors() + vim.g.terminal_color_0 = c.grey1 + vim.g.terminal_color_1 = c.red + vim.g.terminal_color_2 = c.green + vim.g.terminal_color_3 = c.yellow + vim.g.terminal_color_4 = c.blue + vim.g.terminal_color_5 = c.purple + vim.g.terminal_color_6 = c.cyan + vim.g.terminal_color_7 = c.white1 + vim.g.terminal_color_8 = c.grey_bright + vim.g.terminal_color_9 = c.red + vim.g.terminal_color_10 = c.green + vim.g.terminal_color_11 = c.yellow + vim.g.terminal_color_12 = c.blue + vim.g.terminal_color_13 = c.purple + vim.g.terminal_color_14 = c.teal + vim.g.terminal_color_15 = c.white2 +end + +-- Editor related groups +local function highlight_editors() -- Attributes hi('Bold' , '', '', 'bold' , '') hi('Italic' , '', '', 'italic' , '') @@ -112,10 +126,11 @@ function M.highlight() -- Window hi('Title', c.fg, '', '', '') hi('VertSplit', c.grey2, c.black, '', '') +end - -------------------------- - -- Language base groups -- - -------------------------- +-- Syntax groups +local function highlight_syntax() + -- Base syntax hi('Boolean', c.blue, '', '', '') hi('Character', c.fg, '', '', '') hi('Comment', c.grey_bright, '', 'italic', '') @@ -149,36 +164,7 @@ function M.highlight() vim.cmd('hi! link Macro Define') vim.cmd('hi! link PreCondit PreProc') - --------------- - -- Languages -- - --------------- - hi('asciidocAttributeEntry', c.dark_blue, '', '', '') - hi('asciidocAttributeList', c.dark_blue, '', '', '') - hi('asciidocAttributeRef', c.dark_blue, '', '', '') - hi('asciidocHLabel', c.blue, '', '', '') - hi('asciidocListingBlock', c.teal, '', '', '') - hi('asciidocMacroAttributes', c.cyan, '', '', '') - hi('asciidocOneLineTitle', c.cyan, '', '', '') - hi('asciidocPassthroughBlock', c.blue, '', '', '') - hi('asciidocQuotedMonospaced', c.teal, '', '', '') - hi('asciidocTriplePlusPassthrough', c.teal, '', '', '') - vim.cmd('hi! link asciidocAdmonition Keyword') - vim.cmd('hi! link asciidocAttributeRef markdownH1') - vim.cmd('hi! link asciidocBackslash Keyword') - vim.cmd('hi! link asciidocMacro Keyword') - vim.cmd('hi! link asciidocQuotedBold Bold') - vim.cmd('hi! link asciidocQuotedEmphasized Italic') - vim.cmd('hi! link asciidocQuotedMonospaced2 asciidocQuotedMonospaced') - vim.cmd('hi! link asciidocQuotedUnconstrainedBold asciidocQuotedBold') - vim.cmd('hi! link asciidocQuotedUnconstrainedEmphasized asciidocQuotedEmphasized') - vim.cmd('hi! link asciidocURL markdownLinkText') - - hi('awkCharClass', c.teal, '', '', '') - hi('awkPatterns' , c.blue, '', '', '') - vim.cmd('hi! link awkArrayElement Identifier') - vim.cmd('hi! link awkBoolLogic Keyword') - vim.cmd('hi! link awkBrktRegExp SpecialChar') - + -- Diff hi('DiffAdd' , c.green , c.grey1, '', '') hi('DiffChange', c.yellow, c.grey1, '', '') hi('DiffDelete', c.red , c.grey1, '', '') @@ -192,10 +178,59 @@ function M.highlight() vim.cmd('hi! link diffAdded DiffAdd') vim.cmd('hi! link diffRemoved DiffDelete') vim.cmd('hi! link diffChanged DiffChange') +end - --------------------- - -- Plugins' groups -- - --------------------- +-- Treesitter +local function highlight_treesitter() + hi('TSAnnotation' , c.orange, '', '', '') + hi('TSCharacter' , c.fg , '', '', '') + hi('TSConstructor' , c.blue , '', '', '') + hi('TSConstant' , c.fg , '', '', '') + hi('TSFloat' , c.purple, '', '', '') + hi('TSNumber' , c.purple, '', '', '') + hi('TSString' , c.green , '', '', '') + hi('TSAttribute' , c.purple, '', '', '') + hi('TSBoolean' , c.blue , '', '', '') + hi('TSConstBuiltin', c.teal , '', '', '') + hi('TSConstMacro' , c.teal , '', '', '') + hi('TSError' , c.fg , c.red, '', '') + hi('TSException' , c.red , '', 'underline', '') + hi('TSField' , c.fg , '', '', '') + hi('TSFuncMacro' , c.cyan , '', '', '') + hi('TSInclude' , c.teal , '', '', '') + hi('TSLabel' , c.blue , '', '', '') + hi('TSNamespace' , c.teal , '', '', '') + hi('TSOperator' , c.blue , '', '', '') + hi('TSParameter' , c.dark_blue, '', '', '') + hi('TSParameterReference', c.dark_blue, '', '', '') + hi('TSProperty' , c.fg , '', '', '') + hi('TSPunctDelimiter', c.white2, '', '', '') + hi('TSPunctBracket', c.white2, '', '', '') + hi('TSPunctSpecial', c.white2 , '', '', '') + hi('TSStringRegex' , c.teal, '', '', '') + hi('TSStringEscape', c.grey2, '', '', '') + hi('TSSymbol' , c.purple, '', '', '') + hi('TSType' , c.blue , '', '', '') + hi('TSTypeBuiltin' , c.blue, '', '', '') + hi('TSTag' , c.teal, '', '', '') + + -- ts-rainbow + hi('rainbowcol1', c.red, '', 'bold', '') + hi('rainbowcol2', c.orange, '', 'bold', '') + hi('rainbowcol3', c.yellow, '', 'bold', '') + hi('rainbowcol4', c.green, '', 'bold', '') + hi('rainbowcol5', c.cyan, '', 'bold', '') + hi('rainbowcol6', c.blue, '', 'bold', '') + hi('rainbowcol7', c.purple, '', 'bold', '') +end + +-- LSP groups +local function highlight_lsp() + -- TODO +end + +-- Specify groups for plugins +local function highlight_plugins() -- Gitsigns hi('GitSignsAddNr' , c.green , '', '', '') hi('GitSignsChangeNr', c.yellow, '', '', '') @@ -236,47 +271,40 @@ function M.highlight() hi('IndentBlanklineChar', c.grey1, '', '', '') hi('IndentBlanklineContextChar', c.grey1, '', '', '') - -- ts-rainbow - hi('rainbowcol1', c.red, '', 'bold', '') - hi('rainbowcol2', c.orange, '', 'bold', '') - hi('rainbowcol3', c.yellow, '', 'bold', '') - hi('rainbowcol4', c.green, '', 'bold', '') - hi('rainbowcol5', c.cyan, '', 'bold', '') - hi('rainbowcol6', c.blue, '', 'bold', '') - hi('rainbowcol7', c.purple, '', 'bold', '') + -- vim-illuminate + vim.cmd('hi! link illuminatedWord Underline') - -- Treesitter - hi('TSAnnotation' , c.orange, '', '', '') - hi('TSCharacter' , c.fg , '', '', '') - hi('TSConstructor' , c.blue , '', '', '') - hi('TSConstant' , c.fg , '', '', '') - hi('TSFloat' , c.purple, '', '', '') - hi('TSNumber' , c.purple, '', '', '') - hi('TSString' , c.green , '', '', '') - hi('TSAttribute' , c.purple, '', '', '') - hi('TSBoolean' , c.blue , '', '', '') - hi('TSConstBuiltin', c.teal , '', '', '') - hi('TSConstMacro' , c.teal , '', '', '') - hi('TSError' , c.fg , c.red, '', '') - hi('TSException' , c.red , '', 'underline', '') - hi('TSField' , c.fg , '', '', '') - hi('TSFuncMacro' , c.cyan , '', '', '') - hi('TSInclude' , c.teal , '', '', '') - hi('TSLabel' , c.blue , '', '', '') - hi('TSNamespace' , c.teal , '', '', '') - hi('TSOperator' , c.blue , '', '', '') - hi('TSParameter' , c.dark_blue, '', '', '') - hi('TSParameterReference', c.dark_blue, '', '', '') - hi('TSProperty' , c.fg , '', '', '') - hi('TSPunctDelimiter', c.white2, '', '', '') - hi('TSPunctBracket', c.white2, '', '', '') - hi('TSPunctSpecial', c.white2 , '', '', '') - hi('TSStringRegex' , c.teal, '', '', '') - hi('TSStringEscape', c.grey2, '', '', '') - hi('TSSymbol' , c.purple, '', '', '') - hi('TSType' , c.blue , '', '', '') - hi('TSTypeBuiltin' , c.blue, '', '', '') - hi('TSTag' , c.teal, '', '', '') + -- Telescope + hi('TelescopePromptBorder', c.cyan, '', 'bold', '') + hi('TelescopeResultsBorder', c.blue, '', 'bold', '') + hi('TelescopePreviewBorder', c.green, '', 'bold', '') + hi('TelescopeSelection', c.fg, c.grey2, '', '') + hi('TelescopeMultiSelection', c.fg, c.grey2, 'bold', '') + hi('TelescopeSelectionCaret', c.red, c.grey2, 'bold', '') + hi('TelescopeMatching', c.purple, '', 'bold', '') +end + +-- Main function +function M.highlight() + -- Reset everything + 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 + async = vim.loop.new_async(vim.schedule_wrap(function () + set_vim_termcolors() + highlight_plugins() + highlight_treesitter() + highlight_lsp() + async:close() + end)) + + highlight_editors() + highlight_syntax() + async:send() -- Load the rest later end return M diff --git a/home/.config/nvim/lua/events.lua b/home/.config/nvim/lua/events.lua index a1506cd..1a475a7 100644 --- a/home/.config/nvim/lua/events.lua +++ b/home/.config/nvim/lua/events.lua @@ -4,7 +4,7 @@ local M = {} function M.packer_compile() local file = vim.fn.expand('%:p') if file:match(plug_dir) then - vim.api.nvim_command('PackerCompile') + vim.api.nvim_command('source | PackerCompile') end end @@ -23,10 +23,12 @@ end function M.load_autocmds() local definitions = { plugins = { + -- Wrap lines in preview window + -- {"User TelescopePreviewerLoaded", [[setlocal wrap]]}, -- Re-compile packer on config changed {"BufWritePost", "*.lua", "lua require('events').packer_compile()"}, - -- Blankline is lazy-load - {"CursorMoved", [[* IndentBlanklineRefresh]]} + -- Register binding for ToggleTerm inside term mode + {"TermEnter", "term://*toggleterm#*", "tnoremap :ToggleTerm"} }, -- Edit binary files in hex with xxd (:%!xxd and :%!xxd -r) @@ -46,8 +48,8 @@ function M.load_autocmds() {"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"}, {"BufNewFile,BufRead", "*.tex", "setlocal spell"}, -- Auto-hide numbers, statusline in specific buffers - {"BufEnter", "term://*", "setlocal norelativenumber nonumber"}, - {"BufEnter", "term://*", "set laststatus=0"}, + -- {"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]]} }, @@ -64,7 +66,11 @@ function M.load_autocmds() {"FileType", "dashboard", "set showtabline=0 | autocmd WinLeave set showtabline=2"}, {"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"}, {"BufNewFile,BufRead", "*.toml", "setfiletype toml"}, - {"BufNewFile,BufRead", "*.tex", "setfiletype tex"} + {"BufNewFile,BufRead", "*.tex", "setfiletype tex"}, + {"BufNewFile,BufRead", "*.conf", "setfiletype cfg"}, + {"BufNewFile,BufRead", "*.rasi", "setfiletype css"}, + {"BufNewFile,BufRead", "vifmrc,*.vifm", "setfiletype vim"}, + {"BufNewFile,BufRead", "*.log,*_log,*.LO,G*_LOG", "setfiletype log"} }, yank = { diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 88f2985..4d6be27 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -1,9 +1,6 @@ local api = vim.api local wk = require('which-key') --------------------- --- Basic bindings -- --------------------- -- No one likes Esc api.nvim_set_keymap('i', 'jk', [[]], {noremap = true, silent = true}) @@ -14,11 +11,26 @@ api.nvim_set_keymap('t', '', '', {noremap = true, silent = true} api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) --- Normal mode +-- Clear search results +-- api.nvim_set_keymap('n', '', 'noh', {noremap = true, silent = true}) + +----------------- +-- Normal mode -- +----------------- wk.register({ -- Better Y Y = {'y$', 'Yank to eol'}, + -- Easier start and end of line + H = {'^', 'Start of the line'}, + L = {'$', 'End of the line'}, + + -- Easier moving between windows + [''] = {'h', 'Go to the left window'}, + [''] = {'l', 'Go to the right window'}, + [''] = {'j', 'Go to the down window'}, + [''] = {'k', 'Go to the up window'}, + -- Copy the whole buffer [''] = {'%y+', 'Copy whole buffer'}, @@ -58,14 +70,8 @@ wk.register({ ['['] = {name = 'Block motions (previous)'}, [']'] = {name = 'Block motions (next)'}, g = {name = 'Goto motions'}, - z = {name = 'Misc utils'} -}) + z = {name = 'Misc utils'}, -------------- --- Plugins -- -------------- --- Normal mode -wk.register({ -- Don't need to show bufferline numbers ['1'] = 'which_key_ignore', ['2'] = 'which_key_ignore', @@ -85,12 +91,50 @@ wk.register({ [''] = {':NvimTreeToggle', 'NvimTree'}, -- ToggleTerm - [''] = 'Toggle terminal', + [''] = {':ToggleTerm', 'Toggle terminal'} }) --- With leader key (normal mode) +----------------------------------- +-- Normal mode (with leader key) -- +----------------------------------- wk.register({ - -- GitSigns + c = {':ColorizerToggle', 'Toggle colorizer'}, + + b = { + name = 'Buffer', + n = {':DashboardNewFile', 'New file'} + }, + + -- Telescope + f = { + name = 'Telescope', + a = {':Telescope autocommands', 'Autocommands'}, + b = {':Telescope buffers', 'Buffers'}, + c = {':Telescope commands', 'Commands'}, + e = {':Telescope file_browser', 'File browser'}, + f = {':Telescope find_files', 'Find files'}, + g = {':Telescope live_grep', 'Live grep'}, + h = {':Telescope help_tags', 'Help tags'}, + i = {':Telescope highlights', 'Highlight groups'}, + j = {':Telescope symbols', 'Pick emojis'}, + k = {':Telescope keymaps', 'Normal keymaps'}, + m = {':Telescope marks', 'Bookmarks'}, + o = {':Telescope oldfiles', 'Recent files'}, + p = {':Telescope man_pages', 'Man pages'}, + r = {':Telescope reloader', 'Reload lua modules'}, + s = {':Telescope treesitter', 'Treesitter'}, + t = {':Telescope', 'Telescope'}, + u = {':Telescope current_buffer_fuzzy_find', 'Search current buffer'}, + v = {':Telescope vim_options', 'Vim options'}, + y = {':Telescope filetypes', 'Filetypes'}, + z = {':Telescope registers', 'Vim registers'} + }, + + l = { + name = 'LSP' + }, + + -- Git g = { name = 'Git', b = 'Blame current line', @@ -100,21 +144,30 @@ wk.register({ r = 'Reset hunk', R = 'Reset all hunks in buffer', s = 'Stage hunk', - u = 'Undo hunk' + u = 'Undo hunk', + n = {':Neogit', 'Neogit'}, + f = { + name = 'Telescope', + a = {':Telescope git_stash', 'Stash'}, + b = {':Telescope git_bcommits', 'Buffer commits'}, + c = {':Telescope git_commits', 'Commits'}, + m = {':Telescope git_branches', 'Branches'}, + s = {':Telescope git_status', 'Status'} + } }, - -- Telescope - f = { - name = 'Telescope' - }, - - b = { - name = 'Buffer', - n = {':DashboardNewFile', 'New file'} + -- Tab related + t = { + name = 'Tab', + n = {'tabnext', 'Next tab'}, + p = {'tabprev', 'Previous tab'}, + t = {'tabnew', 'New tab'} } }, {prefix = ''}) --- With leader key (visual mode) +----------------------------------- +-- Visual mode (with leader key) -- +----------------------------------- wk.register({ -- GitSigns g = { @@ -123,3 +176,54 @@ wk.register({ s = 'Stage hunk' } }, {mode = 'v', prefix = ''}) + +---------------- +-- nvim-compe -- +---------------- +-- Use (S-)Tab in completion menu +-- See https://github.com/L3MON4D3/Luasnip/issues/1#issuecomment-835241958 +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local function prequire(...) + local status, lib = pcall(require, ...) + if (status) then return lib end + return nil +end + +local luasnip = prequire('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 + +_G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t '' + elseif luasnip and 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 luasnip and luasnip.jumpable(-1) then + return t 'luasnip-jump-prev' + else + return t '' + end +end + +vim.api.nvim_set_keymap('i', '', 'v:lua.tab_complete()', {expr = true, noremap = true, silent = true}) +vim.api.nvim_set_keymap('s', '', 'v:lua.tab_complete()', {expr = true, noremap = true, silent = true}) +vim.api.nvim_set_keymap('i', '', 'v:lua.s_tab_complete()', {expr = true, noremap = true, silent = true}) +vim.api.nvim_set_keymap('s', '', 'v:lua.s_tab_complete()', {expr = true, noremap = true, silent = true}) + +vim.api.nvim_set_keymap('i', '', 'compe#complete()', {expr = true, noremap = true, silent = true}) +vim.api.nvim_set_keymap('i', '', 'compe#close(\'\')', {expr = true, noremap = true, silent = true}) diff --git a/home/.config/nvim/lua/modules/blankline.lua b/home/.config/nvim/lua/modules/blankline.lua index 446f071..9c0b52d 100644 --- a/home/.config/nvim/lua/modules/blankline.lua +++ b/home/.config/nvim/lua/modules/blankline.lua @@ -1,5 +1,6 @@ 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', @@ -40,6 +41,9 @@ local function blankline_options() '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/colorizer.lua b/home/.config/nvim/lua/modules/colorizer.lua index e726bf6..88e8ac7 100644 --- a/home/.config/nvim/lua/modules/colorizer.lua +++ b/home/.config/nvim/lua/modules/colorizer.lua @@ -1,4 +1,4 @@ -return require('colorizer').setup { +return require('colorizer').setup( {'*'}, { RGB = true, -- #RGB hex codes @@ -10,5 +10,4 @@ return require('colorizer').setup { 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 new file mode 100644 index 0000000..212da50 --- /dev/null +++ b/home/.config/nvim/lua/modules/completion.lua @@ -0,0 +1,17 @@ +return require('compe').setup { + enabled = true, + autocomplete = true, + debug = false, + min_length = 1, + preselect = 'always', + source = { + path = true, + buffer = true, + -- calc = true, + nvim_lsp = true, + nvim_lua = true, + luasnip = true, + -- tags = true, + spell = true + } +} diff --git a/home/.config/nvim/lua/modules/dadbod.lua b/home/.config/nvim/lua/modules/dadbod.lua new file mode 100644 index 0000000..e19f7bf --- /dev/null +++ b/home/.config/nvim/lua/modules/dadbod.lua @@ -0,0 +1,10 @@ +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 index f598d89..38765ca 100644 --- a/home/.config/nvim/lua/modules/dashboard.lua +++ b/home/.config/nvim/lua/modules/dashboard.lua @@ -6,11 +6,11 @@ local function dashboard_options() 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 = 'Telescope find_files'}, - b = {description = {' Recents SPC f o'}, command = 'Telescope oldfiles'}, - c = {description = {' Find Word SPC f w'}, command = 'Telescope live_grep'}, + 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 = 'Telescope marks'} + e = {description = {' Bookmarks SPC f m'}, command = 'DashboardJumpMark'} } vim.g.dashboard_custom_header = { " ", diff --git a/home/.config/nvim/lua/modules/markdown-preview.lua b/home/.config/nvim/lua/modules/markdown-preview.lua new file mode 100644 index 0000000..83cc9d7 --- /dev/null +++ b/home/.config/nvim/lua/modules/markdown-preview.lua @@ -0,0 +1,12 @@ +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 index 32165bf..15255ce 100644 --- a/home/.config/nvim/lua/modules/nvimtree.lua +++ b/home/.config/nvim/lua/modules/nvimtree.lua @@ -14,13 +14,13 @@ local function tree_options() default = '', symlink = '', git = { - unstaged = "U", - staged = "S", + unstaged = "", + staged = "", unmerged = "", - renamed = "R", + renamed = "", untracked = "★", - deleted = "D", - ignored = "I" + deleted = "", + ignored = "" }, folder = { arrow_open = "", diff --git a/home/.config/nvim/lua/modules/snippets.lua b/home/.config/nvim/lua/modules/snippets.lua new file mode 100644 index 0000000..bef7bf0 --- /dev/null +++ b/home/.config/nvim/lua/modules/snippets.lua @@ -0,0 +1,11 @@ +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/telescope-nvim.lua b/home/.config/nvim/lua/modules/telescope-nvim.lua new file mode 100644 index 0000000..ceefac2 --- /dev/null +++ b/home/.config/nvim/lua/modules/telescope-nvim.lua @@ -0,0 +1,40 @@ +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 = { + fzf = { + fuzzy = true, + override_generic_sorter = false, + override_file_sorter = true, + case_mode = 'smart_case' + } + } + } + + 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 index 284a567..b3aa046 100644 --- a/home/.config/nvim/lua/modules/terminal.lua +++ b/home/.config/nvim/lua/modules/terminal.lua @@ -1,5 +1,4 @@ return require('toggleterm').setup { - open_mapping = [[]], shade_terminals = false, float_opts = { border = 'curved', diff --git a/home/.config/nvim/lua/modules/ts-rainbow.lua b/home/.config/nvim/lua/modules/ts-rainbow.lua deleted file mode 100644 index 93b63c8..0000000 --- a/home/.config/nvim/lua/modules/ts-rainbow.lua +++ /dev/null @@ -1,7 +0,0 @@ -return require('nvim-treesitter.configs').setup { - rainbow = { - enable = true, - extended_mode = false, - max_file_lines = 1000 - } -} diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index c4414ce..cbaaf1b 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -3,7 +3,7 @@ local opt = vim.opt local function load_options() vim.cmd('filetype indent plugin on') vim.cmd('syntax enable') - vim.cmd('set iskeyword+=-') + -- vim.cmd('set iskeyword+=-') -- General settings opt.mouse = 'nv' @@ -39,7 +39,7 @@ local function load_options() -- opt.cmdwinheight = 6 opt.showtabline = 2 opt.laststatus = 2 - opt.textwidth = 80 + -- opt.textwidth = 80 opt.synmaxcol = 2500 -- opt.shell = 'bash' opt.grepformat = '%f:%l:%c:%m' diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index c242ebf..17544f6 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -1,21 +1,33 @@ local fn,api = vim.fn,vim.api -local packer_dir = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' +local packer_dir = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' if fn.empty(fn.glob(packer_dir)) > 0 then fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir}) api.nvim_command('packadd packer.nvim') end -local packer = require('packer') -local use = packer.use +-- Require since we use 'packer' as opt +vim.cmd [[packadd packer.nvim]] -return packer.startup( - function(use) - use 'wbthomason/packer.nvim' +return require('packer').startup( + function() + use {'wbthomason/packer.nvim', opt = true} - -- UI elements + ----------------- + -- UI elements -- + ----------------- use { 'glepnir/dashboard-nvim', + cmd = { + 'Dashboard', + 'DashboardNewFile', + 'DashboardFindFile', + 'DashboardFindHistory', + 'DashboardFindWord', + 'DashboardJumpMark', + 'SessionLoad', + 'SessionSave' + }, setup = function() require('modules.dashboard') end @@ -48,33 +60,28 @@ return packer.startup( end } - -- Utils - use { - 'akinsho/nvim-toggleterm.lua', - config = function() - require('modules.terminal') - end - } - - -- Git + ------------------ + -- Highlighting -- + ------------------ use { 'lewis6991/gitsigns.nvim', - requires = 'nvim-lua/plenary.nvim', event = {'BufRead', 'BufNewFile'}, + requires = 'nvim-lua/plenary.nvim', config = function() require('modules.gitgutter') end } - - -- Highlighting use { 'norcalli/nvim-colorizer.lua', - event = 'BufRead', + cmd = 'ColorizerToggle', config = function() require('modules.colorizer') - vim.cmd('ColorizerReloadAllBuffers') end } + use { + 'RRethy/vim-illuminate', + event = {'BufRead', 'BufNewFile'} + } use { 'lukas-reineke/indent-blankline.nvim', event = 'BufRead', @@ -94,7 +101,13 @@ return packer.startup( 'p00f/nvim-ts-rainbow', after = 'nvim-treesitter', config = function() - require('modules.ts-rainbow') + require('nvim-treesitter.configs').setup { + rainbow = { + enable = true, + extended_mode = false, + max_file_lines = 1000 + } + } end } use { @@ -102,29 +115,133 @@ return packer.startup( after = 'nvim-treesitter' } - -- LSP - use { - 'neovim/nvim-lspconfig' + --------- + -- LSP -- + --------- + use { -- TODO: config + colors + 'neovim/nvim-lspconfig', + event = 'BufReadPre' + } + use { -- TODO: lua, python, clang + 'kabouzeid/nvim-lspinstall' } use { - 'kabouzeid/nvim-lspinstall', - after = 'nvim-lspconfig' + 'hrsh7th/nvim-compe', + event = 'InsertEnter', + config = function() + require('modules.completion') + end + } + use { + 'L3MON4D3/LuaSnip', -- can't lazy-load (conflicts with autopairs' map_cr) + requires = 'rafamadriz/friendly-snippets', + config = function() + require('modules.snippets') + end } - -- Editing + --------------- + -- Utilities -- + --------------- use { - 'terrortylor/nvim-comment', - after = 'nvim-treesitter', + 'nvim-telescope/telescope.nvim', + cmd = 'Telescope', + requires = { + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-symbols.nvim', + {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} + }, config = function() - require('nvim_comment').setup() + require('modules.telescope-nvim') + end + } + use { -- TODO: colors + config + custom telescope menu + 'pwntester/octo.nvim', + cmd = 'Octo', + wants = 'telescope.nvim', + config = function() + require('octo').setup() + end + } + use { -- TODO: config + colors + 'TimUntersberger/neogit', + cmd = 'Neogit', + requires = { + -- 'sindrets/diffview.nvim', + 'nvim-lua/plenary.nvim' + } + } + 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 } use { 'windwp/nvim-autopairs', - event = 'InsertEnter', + event = 'InsertCharPre', config = function() require('nvim-autopairs').setup() + require('nvim-autopairs.completion.compe').setup({ + map_cr = true, + map_complete = true + }) end } + 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 + } + use { + 'iamcco/markdown-preview.nvim', + run = 'cd app && yarn install', + ft = {'markdown', 'pandoc.markdown', 'rmd'}, + config = function() + require('modules.markdown-preview') + end + } + use { + 'turbio/bracey.vim', + run = 'npm install --prefix server', + cmd = 'Bracey' + } + use { + 'akinsho/nvim-toggleterm.lua', + cmd = 'ToggleTerm', + config = function() + require('modules.terminal') + end + } + + -- Just for benchmarking + use {'tweekmonster/startuptime.vim', cmd = 'StartupTime'} + + -- TODO: trouble.nvim, lspsaga, orgmode.nvim, lspkind, TrueZen/zen-mode, nvim-lint, vim-spectre, nvim-dap, lsp-rooter, hop.nvim, dial.nvim end ) diff --git a/home/.config/ripgrep/config b/home/.config/ripgrep/config index 0e797fb..53db3b3 100644 --- a/home/.config/ripgrep/config +++ b/home/.config/ripgrep/config @@ -1,3 +1,5 @@ +--hidden + --glob !git/*