neovim: almost done

This commit is contained in:
FollieHiyuki 2021-07-10 19:40:43 +03:00
parent d1be74ee0b
commit bc7bdb2bdc
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
18 changed files with 522 additions and 186 deletions

View File

@ -19,12 +19,6 @@ local disable_distribution_plugins = function()
vim.g.loaded_netrwFileHandlers = 1 vim.g.loaded_netrwFileHandlers = 1
end 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() local load_core = function()
-- Global theme -- Global theme
vim.g.global_theme = 'nord' vim.g.global_theme = 'nord'
@ -33,7 +27,7 @@ local load_core = function()
require('options') require('options')
require('colors.' .. vim.g.global_theme).highlight() require('colors.' .. vim.g.global_theme).highlight()
disable_distribution_plugins() disable_distribution_plugins()
leader_map() vim.g.mapleader = ' '
require('plugins') require('plugins')
require('mappings') require('mappings')
require('events').load_autocmds() require('events').load_autocmds()

View File

@ -1,15 +1,7 @@
-- Credit: https://github.com/shaunsingh/nord.nvim
local M = {} 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 = { M.colors = {
black = '#2E3440', black = '#2E3440',
grey1 = '#3B4252', grey1 = '#3B4252',
@ -33,16 +25,38 @@ M.colors = {
local c = M.colors local c = M.colors
function M.highlight() local function hi(group, guifg, guibg, attr, guisp)
-- Reset everything local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE'
vim.cmd('hi clear') local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE'
if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE'
vim.o.background = 'dark' local sp = guisp ~= '' and 'guisp=' .. guisp or ''
vim.o.termguicolors = true
------------------- local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp
-- UI components -- 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 -- Attributes
hi('Bold' , '', '', 'bold' , '') hi('Bold' , '', '', 'bold' , '')
hi('Italic' , '', '', 'italic' , '') hi('Italic' , '', '', 'italic' , '')
@ -112,10 +126,11 @@ function M.highlight()
-- Window -- Window
hi('Title', c.fg, '', '', '') hi('Title', c.fg, '', '', '')
hi('VertSplit', c.grey2, c.black, '', '') hi('VertSplit', c.grey2, c.black, '', '')
end
-------------------------- -- Syntax groups
-- Language base groups -- local function highlight_syntax()
-------------------------- -- Base syntax
hi('Boolean', c.blue, '', '', '') hi('Boolean', c.blue, '', '', '')
hi('Character', c.fg, '', '', '') hi('Character', c.fg, '', '', '')
hi('Comment', c.grey_bright, '', 'italic', '') hi('Comment', c.grey_bright, '', 'italic', '')
@ -149,36 +164,7 @@ function M.highlight()
vim.cmd('hi! link Macro Define') vim.cmd('hi! link Macro Define')
vim.cmd('hi! link PreCondit PreProc') vim.cmd('hi! link PreCondit PreProc')
--------------- -- Diff
-- 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')
hi('DiffAdd' , c.green , c.grey1, '', '') hi('DiffAdd' , c.green , c.grey1, '', '')
hi('DiffChange', c.yellow, c.grey1, '', '') hi('DiffChange', c.yellow, c.grey1, '', '')
hi('DiffDelete', c.red , 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 diffAdded DiffAdd')
vim.cmd('hi! link diffRemoved DiffDelete') vim.cmd('hi! link diffRemoved DiffDelete')
vim.cmd('hi! link diffChanged DiffChange') vim.cmd('hi! link diffChanged DiffChange')
end
--------------------- -- Treesitter
-- Plugins' groups -- 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 -- Gitsigns
hi('GitSignsAddNr' , c.green , '', '', '') hi('GitSignsAddNr' , c.green , '', '', '')
hi('GitSignsChangeNr', c.yellow, '', '', '') hi('GitSignsChangeNr', c.yellow, '', '', '')
@ -236,47 +271,40 @@ function M.highlight()
hi('IndentBlanklineChar', c.grey1, '', '', '') hi('IndentBlanklineChar', c.grey1, '', '', '')
hi('IndentBlanklineContextChar', c.grey1, '', '', '') hi('IndentBlanklineContextChar', c.grey1, '', '', '')
-- ts-rainbow -- vim-illuminate
hi('rainbowcol1', c.red, '', 'bold', '') vim.cmd('hi! link illuminatedWord Underline')
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', '')
-- Treesitter -- Telescope
hi('TSAnnotation' , c.orange, '', '', '') hi('TelescopePromptBorder', c.cyan, '', 'bold', '')
hi('TSCharacter' , c.fg , '', '', '') hi('TelescopeResultsBorder', c.blue, '', 'bold', '')
hi('TSConstructor' , c.blue , '', '', '') hi('TelescopePreviewBorder', c.green, '', 'bold', '')
hi('TSConstant' , c.fg , '', '', '') hi('TelescopeSelection', c.fg, c.grey2, '', '')
hi('TSFloat' , c.purple, '', '', '') hi('TelescopeMultiSelection', c.fg, c.grey2, 'bold', '')
hi('TSNumber' , c.purple, '', '', '') hi('TelescopeSelectionCaret', c.red, c.grey2, 'bold', '')
hi('TSString' , c.green , '', '', '') hi('TelescopeMatching', c.purple, '', 'bold', '')
hi('TSAttribute' , c.purple, '', '', '') end
hi('TSBoolean' , c.blue , '', '', '')
hi('TSConstBuiltin', c.teal , '', '', '') -- Main function
hi('TSConstMacro' , c.teal , '', '', '') function M.highlight()
hi('TSError' , c.fg , c.red, '', '') -- Reset everything
hi('TSException' , c.red , '', 'underline', '') vim.cmd('hi clear')
hi('TSField' , c.fg , '', '', '') if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end
hi('TSFuncMacro' , c.cyan , '', '', '') vim.o.background = 'dark'
hi('TSInclude' , c.teal , '', '', '') vim.o.termguicolors = true
hi('TSLabel' , c.blue , '', '', '')
hi('TSNamespace' , c.teal , '', '', '') -- Load highlight groups
hi('TSOperator' , c.blue , '', '', '') local async
hi('TSParameter' , c.dark_blue, '', '', '') async = vim.loop.new_async(vim.schedule_wrap(function ()
hi('TSParameterReference', c.dark_blue, '', '', '') set_vim_termcolors()
hi('TSProperty' , c.fg , '', '', '') highlight_plugins()
hi('TSPunctDelimiter', c.white2, '', '', '') highlight_treesitter()
hi('TSPunctBracket', c.white2, '', '', '') highlight_lsp()
hi('TSPunctSpecial', c.white2 , '', '', '') async:close()
hi('TSStringRegex' , c.teal, '', '', '') end))
hi('TSStringEscape', c.grey2, '', '', '')
hi('TSSymbol' , c.purple, '', '', '') highlight_editors()
hi('TSType' , c.blue , '', '', '') highlight_syntax()
hi('TSTypeBuiltin' , c.blue, '', '', '') async:send() -- Load the rest later
hi('TSTag' , c.teal, '', '', '')
end end
return M return M

View File

@ -4,7 +4,7 @@ local M = {}
function M.packer_compile() function M.packer_compile()
local file = vim.fn.expand('%:p') local file = vim.fn.expand('%:p')
if file:match(plug_dir) then if file:match(plug_dir) then
vim.api.nvim_command('PackerCompile') vim.api.nvim_command('source <afile> | PackerCompile')
end end
end end
@ -23,10 +23,12 @@ end
function M.load_autocmds() function M.load_autocmds()
local definitions = { local definitions = {
plugins = { plugins = {
-- Wrap lines in preview window
-- {"User TelescopePreviewerLoaded", [[setlocal wrap]]},
-- Re-compile packer on config changed -- Re-compile packer on config changed
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"}, {"BufWritePost", "*.lua", "lua require('events').packer_compile()"},
-- Blankline is lazy-load -- Register binding for ToggleTerm inside term mode
{"CursorMoved", [[* IndentBlanklineRefresh]]} {"TermEnter", "term://*toggleterm#*", "tnoremap <silent><C-\\> <C-\\><C-n>:ToggleTerm<CR>"}
}, },
-- Edit binary files in hex with xxd (:%!xxd and :%!xxd -r) -- 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", "*.md,*.mkd", "setlocal spell"},
{"BufNewFile,BufRead", "*.tex", "setlocal spell"}, {"BufNewFile,BufRead", "*.tex", "setlocal spell"},
-- Auto-hide numbers, statusline in specific buffers -- Auto-hide numbers, statusline in specific buffers
{"BufEnter", "term://*", "setlocal norelativenumber nonumber"}, -- {"BufEnter", "term://*", "setlocal norelativenumber nonumber"},
{"BufEnter", "term://*", "set laststatus=0"}, -- {"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]]}
}, },
@ -64,7 +66,11 @@ function M.load_autocmds()
{"FileType", "dashboard", "set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2"}, {"FileType", "dashboard", "set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2"},
{"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"}, {"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"},
{"BufNewFile,BufRead", "*.toml", "setfiletype toml"}, {"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 = { yank = {

View File

@ -1,9 +1,6 @@
local api = vim.api local api = vim.api
local wk = require('which-key') local wk = require('which-key')
--------------------
-- Basic bindings --
--------------------
-- No one likes Esc -- No one likes Esc
api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true}) api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true})
@ -14,11 +11,26 @@ api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true}
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
-- Normal mode -- Clear search results
-- api.nvim_set_keymap('n', '<Esc>', '<Cmd>noh<CR>', {noremap = true, silent = true})
-----------------
-- Normal mode --
-----------------
wk.register({ wk.register({
-- Better Y -- Better Y
Y = {'y$', 'Yank to eol'}, 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
['<C-h>'] = {'<C-w>h', 'Go to the left window'},
['<C-l>'] = {'<C-w>l', 'Go to the right window'},
['<C-j>'] = {'<C-w>j', 'Go to the down window'},
['<C-k>'] = {'<C-w>k', 'Go to the up window'},
-- Copy the whole buffer -- Copy the whole buffer
['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'}, ['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'},
@ -58,14 +70,8 @@ wk.register({
['['] = {name = 'Block motions (previous)'}, ['['] = {name = 'Block motions (previous)'},
[']'] = {name = 'Block motions (next)'}, [']'] = {name = 'Block motions (next)'},
g = {name = 'Goto motions'}, g = {name = 'Goto motions'},
z = {name = 'Misc utils'} z = {name = 'Misc utils'},
})
-------------
-- Plugins --
-------------
-- Normal mode
wk.register({
-- Don't need to show bufferline numbers -- Don't need to show bufferline numbers
['<leader>1'] = 'which_key_ignore', ['<leader>1'] = 'which_key_ignore',
['<leader>2'] = 'which_key_ignore', ['<leader>2'] = 'which_key_ignore',
@ -85,12 +91,50 @@ wk.register({
['<C-n>'] = {':NvimTreeToggle<CR>', 'NvimTree'}, ['<C-n>'] = {':NvimTreeToggle<CR>', 'NvimTree'},
-- ToggleTerm -- ToggleTerm
['<C-\\>'] = 'Toggle terminal', ['<C-\\>'] = {':ToggleTerm<CR>', 'Toggle terminal'}
}) })
-- With leader key (normal mode) -----------------------------------
-- Normal mode (with leader key) --
-----------------------------------
wk.register({ wk.register({
-- GitSigns c = {':ColorizerToggle<CR>', 'Toggle colorizer'},
b = {
name = 'Buffer',
n = {':DashboardNewFile<CR>', 'New file'}
},
-- Telescope
f = {
name = 'Telescope',
a = {':Telescope autocommands<CR>', 'Autocommands'},
b = {':Telescope buffers<CR>', 'Buffers'},
c = {':Telescope commands<CR>', 'Commands'},
e = {':Telescope file_browser<CR>', 'File browser'},
f = {':Telescope find_files<CR>', 'Find files'},
g = {':Telescope live_grep<CR>', 'Live grep'},
h = {':Telescope help_tags<CR>', 'Help tags'},
i = {':Telescope highlights<CR>', 'Highlight groups'},
j = {':Telescope symbols<CR>', 'Pick emojis'},
k = {':Telescope keymaps<CR>', 'Normal keymaps'},
m = {':Telescope marks<CR>', 'Bookmarks'},
o = {':Telescope oldfiles<CR>', 'Recent files'},
p = {':Telescope man_pages<CR>', 'Man pages'},
r = {':Telescope reloader<CR>', 'Reload lua modules'},
s = {':Telescope treesitter<CR>', 'Treesitter'},
t = {':Telescope<CR>', 'Telescope'},
u = {':Telescope current_buffer_fuzzy_find<CR>', 'Search current buffer'},
v = {':Telescope vim_options<CR>', 'Vim options'},
y = {':Telescope filetypes<CR>', 'Filetypes'},
z = {':Telescope registers<CR>', 'Vim registers'}
},
l = {
name = 'LSP'
},
-- Git
g = { g = {
name = 'Git', name = 'Git',
b = 'Blame current line', b = 'Blame current line',
@ -100,21 +144,30 @@ wk.register({
r = 'Reset hunk', r = 'Reset hunk',
R = 'Reset all hunks in buffer', R = 'Reset all hunks in buffer',
s = 'Stage hunk', s = 'Stage hunk',
u = 'Undo hunk' u = 'Undo hunk',
n = {':Neogit<CR>', 'Neogit'},
f = {
name = 'Telescope',
a = {':Telescope git_stash<CR>', 'Stash'},
b = {':Telescope git_bcommits<CR>', 'Buffer commits'},
c = {':Telescope git_commits<CR>', 'Commits'},
m = {':Telescope git_branches<CR>', 'Branches'},
s = {':Telescope git_status<CR>', 'Status'}
}
}, },
-- Telescope -- Tab related
f = { t = {
name = 'Telescope' name = 'Tab',
}, n = {'<Cmd>tabnext<CR>', 'Next tab'},
p = {'<Cmd>tabprev<CR>', 'Previous tab'},
b = { t = {'<Cmd>tabnew<CR>', 'New tab'}
name = 'Buffer',
n = {':DashboardNewFile<CR>', 'New file'}
} }
}, {prefix = '<leader>'}) }, {prefix = '<leader>'})
-- With leader key (visual mode) -----------------------------------
-- Visual mode (with leader key) --
-----------------------------------
wk.register({ wk.register({
-- GitSigns -- GitSigns
g = { g = {
@ -123,3 +176,54 @@ wk.register({
s = 'Stage hunk' s = 'Stage hunk'
} }
}, {mode = 'v', prefix = '<leader>'}) }, {mode = 'v', prefix = '<leader>'})
----------------
-- 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 '<C-n>'
elseif luasnip and luasnip.expand_or_jumpable() then
return t '<Plug>luasnip-expand-or-jump'
elseif check_back_space() then
return t '<Tab>'
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t '<C-p>'
elseif luasnip and luasnip.jumpable(-1) then
return t '<Plug>luasnip-jump-prev'
else
return t '<S-Tab>'
end
end
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', {expr = true, noremap = true, silent = true})
vim.api.nvim_set_keymap('s', '<Tab>', 'v:lua.tab_complete()', {expr = true, noremap = true, silent = true})
vim.api.nvim_set_keymap('i', '<S-Tab>', 'v:lua.s_tab_complete()', {expr = true, noremap = true, silent = true})
vim.api.nvim_set_keymap('s', '<S-Tab>', 'v:lua.s_tab_complete()', {expr = true, noremap = true, silent = true})
vim.api.nvim_set_keymap('i', '<C-Space>', 'compe#complete()', {expr = true, noremap = true, silent = true})
vim.api.nvim_set_keymap('i', '<C-e>', 'compe#close(\'<C-e>\')', {expr = true, noremap = true, silent = true})

View File

@ -1,5 +1,6 @@
local function blankline_options() local function blankline_options()
vim.g.indent_blankline_char = '' vim.g.indent_blankline_char = ''
-- vim.g.indent_blankline_space_char = '·'
vim.g.indent_blankline_show_first_indent_level = true vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_filetype_exclude = { vim.g.indent_blankline_filetype_exclude = {
'startify', 'startify',
@ -40,6 +41,9 @@ local function blankline_options()
'while', 'while',
'for' 'for'
} }
-- Refresh often, since it is lazy-loaded
-- vim.cmd('autocmd CursorMoved * IndentBlanklineRefresh')
end end
blankline_options() blankline_options()

View File

@ -1,4 +1,4 @@
return require('colorizer').setup { return require('colorizer').setup(
{'*'}, {'*'},
{ {
RGB = true, -- #RGB hex codes 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 = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background' -- Set the display mode. mode = 'background' -- Set the display mode.
} })
}

View File

@ -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
}
}

View File

@ -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()

View File

@ -6,11 +6,11 @@ local function dashboard_options()
vim.g.dashboard_default_executive = 'telescope' vim.g.dashboard_default_executive = 'telescope'
vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions' vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions'
vim.g.dashboard_custom_section = { vim.g.dashboard_custom_section = {
a = {description = {' Find File SPC f f'}, command = 'Telescope find_files'}, a = {description = {' Find File SPC f f'}, command = 'DashboardFindFile'},
b = {description = {' Recents SPC f o'}, command = 'Telescope oldfiles'}, b = {description = {' Recents SPC f o'}, command = 'DashboardFindHistory'},
c = {description = {' Find Word SPC f w'}, command = 'Telescope live_grep'}, c = {description = {' Find Word SPC f g'}, command = 'DashboardFindWord'},
d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'}, 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 = { vim.g.dashboard_custom_header = {
" ", " ",

View File

@ -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()

View File

@ -14,13 +14,13 @@ local function tree_options()
default = '', default = '',
symlink = '', symlink = '',
git = { git = {
unstaged = "U", unstaged = "",
staged = "S", staged = "",
unmerged = "", unmerged = "",
renamed = "R", renamed = "",
untracked = "", untracked = "",
deleted = "D", deleted = "",
ignored = "I" ignored = ""
}, },
folder = { folder = {
arrow_open = "", arrow_open = "",

View File

@ -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()

View File

@ -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()

View File

@ -1,5 +1,4 @@
return require('toggleterm').setup { return require('toggleterm').setup {
open_mapping = [[<c-\>]],
shade_terminals = false, shade_terminals = false,
float_opts = { float_opts = {
border = 'curved', border = 'curved',

View File

@ -1,7 +0,0 @@
return require('nvim-treesitter.configs').setup {
rainbow = {
enable = true,
extended_mode = false,
max_file_lines = 1000
}
}

View File

@ -3,7 +3,7 @@ local opt = vim.opt
local function load_options() local function load_options()
vim.cmd('filetype indent plugin on') vim.cmd('filetype indent plugin on')
vim.cmd('syntax enable') vim.cmd('syntax enable')
vim.cmd('set iskeyword+=-') -- vim.cmd('set iskeyword+=-')
-- General settings -- General settings
opt.mouse = 'nv' opt.mouse = 'nv'
@ -39,7 +39,7 @@ local function load_options()
-- opt.cmdwinheight = 6 -- opt.cmdwinheight = 6
opt.showtabline = 2 opt.showtabline = 2
opt.laststatus = 2 opt.laststatus = 2
opt.textwidth = 80 -- opt.textwidth = 80
opt.synmaxcol = 2500 opt.synmaxcol = 2500
-- opt.shell = 'bash' -- opt.shell = 'bash'
opt.grepformat = '%f:%l:%c:%m' opt.grepformat = '%f:%l:%c:%m'

View File

@ -1,21 +1,33 @@
local fn,api = vim.fn,vim.api 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 if fn.empty(fn.glob(packer_dir)) > 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir}) fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir})
api.nvim_command('packadd packer.nvim') api.nvim_command('packadd packer.nvim')
end end
local packer = require('packer') -- Require since we use 'packer' as opt
local use = packer.use vim.cmd [[packadd packer.nvim]]
return packer.startup( return require('packer').startup(
function(use) function()
use 'wbthomason/packer.nvim' use {'wbthomason/packer.nvim', opt = true}
-- UI elements -----------------
-- UI elements --
-----------------
use { use {
'glepnir/dashboard-nvim', 'glepnir/dashboard-nvim',
cmd = {
'Dashboard',
'DashboardNewFile',
'DashboardFindFile',
'DashboardFindHistory',
'DashboardFindWord',
'DashboardJumpMark',
'SessionLoad',
'SessionSave'
},
setup = function() setup = function()
require('modules.dashboard') require('modules.dashboard')
end end
@ -48,33 +60,28 @@ return packer.startup(
end end
} }
-- Utils ------------------
use { -- Highlighting --
'akinsho/nvim-toggleterm.lua', ------------------
config = function()
require('modules.terminal')
end
}
-- Git
use { use {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
event = {'BufRead', 'BufNewFile'}, event = {'BufRead', 'BufNewFile'},
requires = 'nvim-lua/plenary.nvim',
config = function() config = function()
require('modules.gitgutter') require('modules.gitgutter')
end end
} }
-- Highlighting
use { use {
'norcalli/nvim-colorizer.lua', 'norcalli/nvim-colorizer.lua',
event = 'BufRead', cmd = 'ColorizerToggle',
config = function() config = function()
require('modules.colorizer') require('modules.colorizer')
vim.cmd('ColorizerReloadAllBuffers')
end end
} }
use {
'RRethy/vim-illuminate',
event = {'BufRead', 'BufNewFile'}
}
use { use {
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
event = 'BufRead', event = 'BufRead',
@ -94,7 +101,13 @@ return packer.startup(
'p00f/nvim-ts-rainbow', 'p00f/nvim-ts-rainbow',
after = 'nvim-treesitter', after = 'nvim-treesitter',
config = function() config = function()
require('modules.ts-rainbow') require('nvim-treesitter.configs').setup {
rainbow = {
enable = true,
extended_mode = false,
max_file_lines = 1000
}
}
end end
} }
use { use {
@ -102,29 +115,133 @@ return packer.startup(
after = 'nvim-treesitter' after = 'nvim-treesitter'
} }
-- LSP ---------
use { -- LSP --
'neovim/nvim-lspconfig' ---------
use { -- TODO: config + colors
'neovim/nvim-lspconfig',
event = 'BufReadPre'
}
use { -- TODO: lua, python, clang
'kabouzeid/nvim-lspinstall'
} }
use { use {
'kabouzeid/nvim-lspinstall', 'hrsh7th/nvim-compe',
after = 'nvim-lspconfig' 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 { use {
'terrortylor/nvim-comment', 'nvim-telescope/telescope.nvim',
after = 'nvim-treesitter', 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() 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 end
} }
use { use {
'windwp/nvim-autopairs', 'windwp/nvim-autopairs',
event = 'InsertEnter', event = 'InsertCharPre',
config = function() config = function()
require('nvim-autopairs').setup() require('nvim-autopairs').setup()
require('nvim-autopairs.completion.compe').setup({
map_cr = true,
map_complete = true
})
end 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 end
) )

View File

@ -1,3 +1,5 @@
--hidden
--glob --glob
!git/* !git/*