mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-28 18:28:35 -05:00
neovim: almost done
This commit is contained in:
parent
d1be74ee0b
commit
bc7bdb2bdc
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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 <afile> | 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 <silent><C-\\> <C-\\><C-n>:ToggleTerm<CR>"}
|
||||
},
|
||||
|
||||
-- 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 <buffer> 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 = {
|
||||
|
@ -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', [[<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})
|
||||
|
||||
-- Normal mode
|
||||
-- Clear search results
|
||||
-- api.nvim_set_keymap('n', '<Esc>', '<Cmd>noh<CR>', {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
|
||||
['<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
|
||||
['<C-a>'] = {'<Cmd>%y+<CR>', '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
|
||||
['<leader>1'] = 'which_key_ignore',
|
||||
['<leader>2'] = 'which_key_ignore',
|
||||
@ -85,12 +91,50 @@ wk.register({
|
||||
['<C-n>'] = {':NvimTreeToggle<CR>', 'NvimTree'},
|
||||
|
||||
-- ToggleTerm
|
||||
['<C-\\>'] = 'Toggle terminal',
|
||||
['<C-\\>'] = {':ToggleTerm<CR>', 'Toggle terminal'}
|
||||
})
|
||||
|
||||
-- With leader key (normal mode)
|
||||
-----------------------------------
|
||||
-- Normal mode (with leader key) --
|
||||
-----------------------------------
|
||||
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 = {
|
||||
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<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
|
||||
f = {
|
||||
name = 'Telescope'
|
||||
},
|
||||
|
||||
b = {
|
||||
name = 'Buffer',
|
||||
n = {':DashboardNewFile<CR>', 'New file'}
|
||||
-- Tab related
|
||||
t = {
|
||||
name = 'Tab',
|
||||
n = {'<Cmd>tabnext<CR>', 'Next tab'},
|
||||
p = {'<Cmd>tabprev<CR>', 'Previous tab'},
|
||||
t = {'<Cmd>tabnew<CR>', 'New tab'}
|
||||
}
|
||||
}, {prefix = '<leader>'})
|
||||
|
||||
-- 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 = '<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})
|
||||
|
@ -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()
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
})
|
||||
|
17
home/.config/nvim/lua/modules/completion.lua
Normal file
17
home/.config/nvim/lua/modules/completion.lua
Normal 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
|
||||
}
|
||||
}
|
10
home/.config/nvim/lua/modules/dadbod.lua
Normal file
10
home/.config/nvim/lua/modules/dadbod.lua
Normal 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()
|
@ -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 = {
|
||||
" ",
|
||||
|
12
home/.config/nvim/lua/modules/markdown-preview.lua
Normal file
12
home/.config/nvim/lua/modules/markdown-preview.lua
Normal 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()
|
@ -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 = "",
|
||||
|
11
home/.config/nvim/lua/modules/snippets.lua
Normal file
11
home/.config/nvim/lua/modules/snippets.lua
Normal 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()
|
40
home/.config/nvim/lua/modules/telescope-nvim.lua
Normal file
40
home/.config/nvim/lua/modules/telescope-nvim.lua
Normal 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()
|
@ -1,5 +1,4 @@
|
||||
return require('toggleterm').setup {
|
||||
open_mapping = [[<c-\>]],
|
||||
shade_terminals = false,
|
||||
float_opts = {
|
||||
border = 'curved',
|
||||
|
@ -1,7 +0,0 @@
|
||||
return require('nvim-treesitter.configs').setup {
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = false,
|
||||
max_file_lines = 1000
|
||||
}
|
||||
}
|
@ -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'
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -1,3 +1,5 @@
|
||||
--hidden
|
||||
|
||||
--glob
|
||||
!git/*
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user