neovim: gitsigns, basic mappings and nord colors

Also update nushell startup hook
This commit is contained in:
FollieHiyuki 2021-07-07 11:08:00 +03:00
parent c447ef8282
commit 0098bc351f
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
12 changed files with 365 additions and 36 deletions

View File

@ -1,9 +1,12 @@
skip_welcome_message = true skip_welcome_message = true
prompt = "__zoxide_hook; starship prompt"
startup = [ startup = [
"zoxide init nushell --hook prompt | save ~/.local/share/nu/zoxide.nu", "mkdir ~/.cache/nu",
"source ~/.local/share/nu/zoxide.nu" "zoxide init nushell --hook prompt | save ~/.cache/nu/zoxide.nu",
] "source ~/.cache/nu/zoxide.nu",
"starship init nu | save ~/.cache/nu/starship.nu",
"source ~/.cache/nu/starship.nu"
]
prompt = "__zoxide_hook; starship prompt"
[line_editor] [line_editor]
completion_type = "list" completion_type = "list"

View File

@ -9,7 +9,7 @@ local disable_distribution_plugins = function()
vim.g.loaded_vimball = 1 vim.g.loaded_vimball = 1
vim.g.loaded_vimballPlugin = 1 vim.g.loaded_vimballPlugin = 1
vim.g.loaded_matchit = 1 vim.g.loaded_matchit = 1
vim.g.loaded_matchparen = 1 -- vim.g.loaded_matchparen = 1
vim.g.loaded_2html_plugin = 1 vim.g.loaded_2html_plugin = 1
vim.g.loaded_logiPat = 1 vim.g.loaded_logiPat = 1
vim.g.loaded_rrhelper = 1 vim.g.loaded_rrhelper = 1
@ -31,11 +31,12 @@ local load_core = function()
-- Config -- Config
require('options') require('options')
require('colors.' .. vim.g.global_theme).highlight()
disable_distribution_plugins() disable_distribution_plugins()
leader_map() leader_map()
require('plugins') require('plugins')
require('colors.' .. vim.g.global_theme).highlight()
require('events').load_autocmds() require('events').load_autocmds()
require('mappings')
end end
load_core() load_core()

View File

@ -1,18 +1,17 @@
local api = vim.api
local M = {} local M = {}
local function hi(group, guifg, guibg, attr, guisp) local function hi(group, guifg, guibg, attr, guisp)
if guifg ~= '' then if guifg ~= '' then
api.nvim_command('hi ' .. group .. ' guifg=' .. guifg) vim.cmd('hi ' .. group .. ' guifg=' .. guifg)
end end
if guibg ~= '' then if guibg ~= '' then
api.nvim_command('hi ' .. group .. ' guibg=' .. guibg) vim.cmd('hi ' .. group .. ' guibg=' .. guibg)
end end
if attr ~= '' then if attr ~= '' then
api.nvim_command('hi ' .. group .. ' gui=' .. attr) vim.cmd('hi ' .. group .. ' gui=' .. attr)
end end
if guisp ~= '' then if guisp ~= '' then
api.nvim_command('hi ' .. group .. ' guisp=' .. guisp) vim.cmd('hi ' .. group .. ' guisp=' .. guisp)
end end
end end
@ -38,8 +37,166 @@ M.colors = {
none = 'NONE' none = 'NONE'
} }
local c = M.colors
function M.highlight() function M.highlight()
hi('ModeMsg', M.colors.green, '', '', '') -- 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
-------------------
-- UI components --
-------------------
-- Attributes
hi('Bold' , '', '', 'bold' , '')
hi('Italic' , '', '', 'italic' , '')
hi('Underline', '', '', 'underline', '')
-- Editor
hi('ColorColumn', '' , c.grey1, '', '')
hi('Cursor' , c.black , c.fg , '', '')
hi('CursorLine' , c.grey1 , '' , 'NONE', '')
hi('Error' , c.fg , c.red , '', '')
hi('iCursor' , c.black , c.fg , '', '')
hi('LineNr' , c.grey3 , c.none , '', '')
hi('MatchParen' , c.cyan , c.grey3, '', '')
hi('NonText' , c.grey2 , '' , '', '')
hi('Normal' , c.fg , c.black, '', '')
hi('Pmenu' , c.fg , c.grey2, 'NONE', '')
hi('PmenuSbar' , c.fg , c.grey2, '', '')
hi('PmenuSel' , c.cyan , c.grey3, '', '')
hi('PmenuThumb' , c.cyan , c.grey3, '', '')
hi('SpecialKey' , c.grey3 , '' , '', '')
hi('SpellBad' , c.red , c.black, 'undercurl', c.red)
hi('SpellCap' , c.yellow, c.black, 'undercurl', c.yellow)
hi('SpellLocal' , c.white1, c.black, 'undercurl', c.white1)
hi('SpellRare' , c.white2, c.black, 'undercurl', c.white2)
hi('Visual' , '' , c.grey2 , '', '')
hi('VisualNOS' , '' , c.grey2 , '', '')
-- Neovim support
hi('healthError' , c.red , c.grey1, '', '')
hi('healthSuccess', c.green , c.grey1, '', '')
hi('healthWarning', c.yellow, c.grey1, '', '')
hi('TermCursorNC' , '' , c.grey2, '', '')
-- Gutter
hi('CursorColumn', c.grey1, '' , '' , '')
hi('CursorLineNr', c.fg , '' , 'NONE', '')
hi('Folded' , c.grey3, c.grey1, 'bold', '')
hi('FoldColumn' , c.grey3, c.black, '' , '')
hi('SignColumn' , c.grey1, c.black, '' , '')
-- Navigation
hi('Directory', c.cyan, '', '', '')
-- Prompt
hi('EndOfBuffer', c.grey1, '' , '', '')
hi('ErrorMsg' , c.fg , c.red , '', '')
hi('ModeMsg' , c.green, '' , '', '')
hi('MoreMsg' , c.cyan , '' , '', '')
hi('Question' , c.fg , '' , '', '')
hi('WarningMsg' , c.black, c.yellow, '', '')
hi('WildMenu' , c.cyan , c.grey1 , '', '')
-- Statusline
hi('StatusLine' , c.cyan, c.grey3, 'NONE', '')
hi('StatusLineNC' , c.fg , c.grey3, 'NONE', '')
hi('StatusLineTerm' , c.cyan, c.grey3, 'NONE', '')
hi('StatusLineTermNC', c.fg , c.grey3, 'NONE', '')
-- Search
hi('IncSearch', c.white2, c.dark_blue, 'underline', '')
hi('Search' , c.grey1 , c.cyan , 'NONE' , '')
-- Tabline
hi('TabLine' , c.fg , c.grey1, 'NONE', '')
hi('TabLineFill', c.fg , c.grey1, 'NONE', '')
hi('TabLineSel' , c.cyan, c.grey3, 'NONE', '')
-- Window
hi('Title', c.fg, '', 'NONE', '')
hi('VertSplit', c.grey2, c.black, 'NONE', '')
--------------------------
-- Language base groups --
--------------------------
hi('Boolean', c.blue, '', '', '')
hi('Character', c.fg, '', '', '')
hi('Comment', c.grey_bright, '', 'italic', '')
hi('Conceal', '', '', '', '')
hi('Conditional', c.blue, '', '', '')
hi('Constant', c.fg, '', '', '')
hi('Define', c.blue, '', '', '')
hi('Delimiter', c.white2, '', '', '')
hi('Exception', c.blue, '', '', '')
hi('Float', c.purple, '', '', '')
hi('Function', c.cyan, '', '', '')
hi('Identifier', c.fg, '', 'NONE', '')
hi('Include', c.blue, '', '', '')
hi('Keyword', c.blue, '', '', '')
hi('Label', c.blue, '', '', '')
hi('Number', c.purple, '', '', '')
hi('Operator', c.blue, '', 'NONE', '')
hi('PreProc', c.blue, '', 'NONE', '')
hi('Repeat', c.blue, '', '', '')
hi('Special', c.fg, '', '', '')
hi('SpecialChar', c.yellow, '', '', '')
hi('SpecialComment', c.cyan, '', 'italic', '')
hi('Statement', c.blue, '', '', '')
hi('StorageClass', c.blue, '', '', '')
hi('String', c.green, '', '', '')
hi('Structure', c.blue, '', '', '')
hi('Tag', c.fg, '', '', '')
hi('Todo', c.yellow, c.none, '', '')
hi('Type', c.blue, '', 'NONE', '')
hi('Typedef', c.blue, '', '', '')
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('DiffAdd' , c.green , c.grey1, '', '')
hi('DiffChange', c.yellow, c.grey1, '', '')
hi('DiffDelete', c.red , c.grey1, '', '')
hi('DiffText' , c.blue , c.grey1, '', '')
---------------------
-- Plugins' groups --
---------------------
-- Gitsigns
hi('GitSignsAddNr' , c.green , '', '', '')
hi('GitSignsChangeNr', c.yellow, '', '', '')
hi('GitSignsDeleteNr', c.red , '', '', '')
-- Dashboard
hi('DashboardHeader' , c.cyan , '', 'bold' , '')
hi('DashboardCenter' , c.blue , '', 'bold' , '')
hi('DashboardShortcut', c.grey_bright, '', 'bold,italic', '')
hi('DashboardFooter' , c.green , '', 'bold' , '')
end end
return M return M

View File

@ -1,18 +1,17 @@
local api = vim.api
local M = {} local M = {}
local function hi(group, guifg, guibg, attr, guisp) local function hi(group, guifg, guibg, attr, guisp)
if guifg ~= '' then if guifg ~= '' then
api.nvim_command('hi ' .. group .. ' guifg=' .. guifg) vim.cmd('hi ' .. group .. ' guifg=' .. guifg)
end end
if guibg ~= '' then if guibg ~= '' then
api.nvim_command('hi ' .. group .. ' guibg=' .. guibg) vim.cmd('hi ' .. group .. ' guibg=' .. guibg)
end end
if attr ~= '' then if attr ~= '' then
api.nvim_command('hi ' .. group .. ' gui=' .. attr) vim.cmd('hi ' .. group .. ' gui=' .. attr)
end end
if guisp ~= '' then if guisp ~= '' then
api.nvim_command('hi ' .. group .. ' guisp=' .. guisp) vim.cmd('hi ' .. group .. ' guisp=' .. guisp)
end end
end end
@ -39,8 +38,10 @@ M.colors = {
none = 'NONE' none = 'NONE'
} }
local c = M.colors
function M.highlight() function M.highlight()
hi('ModeMsg', M.colors.green, '', '', '') hi('ModeMsg', c.green, '', '', '')
end end
return M return M

View File

@ -0,0 +1,66 @@
local function map(mode, lhs, rhs, opts)
local options = {noremap = true, silent = true}
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
local opt = {}
--------------------
-- Basic bindings --
--------------------
-- No one likes Esc
map('i', 'jk', [[<Esc>]], opt)
-- Better Y
map('n', 'Y', [[y$]], opt)
-- Continuous indent
map('v', '<', '<gv', opt)
map('v', '>', '>gv', opt)
-- Escape mode in terminal buffer
map('t', '<Esc>', '<C-\\><C-n>', opt)
-- Copy the whole buffer
map('n', '<C-a>', [[ <Cmd> %y+<CR>]], opt)
-- 'Legacy' save file
-- map('n', '<C-s>', ':w <CR>', opt)
-- Close buffer
map('n', '<C-x>', ':bd!<CR>', opt)
-- Remove trailing whitespace
map('n', '<A-w>', ':%s/\\s\\+$//e<CR>', opt)
-- Resize buffer
map('n', '<A-j>', ':resize -2<CR>', opt)
map('n', '<A-k>', ':resize +2<CR>', opt)
map('n', '<A-h>', ':vertical resize -2<CR>', opt)
map('n', '<A-l>', ':vertical resize +2<CR>', opt)
-- Switch between tabs and spaces
function toggleIndentStyle()
if vim.o.expandtab == true then
vim.cmd('set noexpandtab nosmarttab softtabstop& shiftwidth&')
vim.cmd('echomsg "Switched to indent with tabs"')
else
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.cmd('echomsg "Switched to indent with 4 spaces"')
end
end
map('n', '<A-t>', ':lua toggleIndentStyle()<CR>', opt)
-----------------------
-- Plugins' bindings --
-----------------------
-- Move between tabs
map('n', '<TAB>', [[<Cmd>BufferLineCycleNext<CR>]], opt)
map('n', '<S-TAB>', [[<Cmd>BufferLineCyclePrev<CR>]], opt)
-- NvimTree
map('n', '<C-n>', ':NvimTreeToggle<CR>', opt)

View File

@ -1,14 +1,30 @@
return require('bufferline').setup { return require('bufferline').setup {
options = { options = {
numbers = 'none',
mappings = true, mappings = true,
max_name_length = 18, max_name_length = 16,
max_prefix_length = 16, max_prefix_length = 14,
tab_size = 18, tab_size = 20,
diagnostics = 'nvim_lsp', diagnostics = 'nvim_lsp',
show_close_icon = false,
show_buffer_icons = true,
show_tab_indicators = true, show_tab_indicators = true,
enforce_regular_tabs = false, enforce_regular_tabs = false,
show_buffer_close_icons = true, show_buffer_close_icons = true,
always_show_bufferline = true, always_show_bufferline = true,
offsets = {
{filetype = 'NvimTree', text = 'NvimTree', text_align = 'left'},
{filetype = 'packer', text = 'Packer', text_align = 'left'}
},
separator_style = 'thin' separator_style = 'thin'
},
highlights = {
fill = {
guibg = {
attribute = 'bg',
highlight = 'TabLineFill'
}
}
} }
} }

View File

@ -9,8 +9,8 @@ local function dashboard_options()
a = {description = {' Find File SPC f f'}, command = 'Telescope find_files'}, a = {description = {' Find File SPC f f'}, command = 'Telescope find_files'},
b = {description = {' Recents SPC f o'}, command = 'Telescope oldfiles'}, b = {description = {' Recents SPC f o'}, command = 'Telescope oldfiles'},
c = {description = {' Find Word SPC f w'}, command = 'Telescope live_grep'}, c = {description = {' Find Word SPC f w'}, command = 'Telescope live_grep'},
d = {description = {'洛 New File SPC f n'}, command = 'DashboardNewFile'}, d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'},
e = {description = {' Bookmarks SPC b m'}, command = 'Telescope marks'}, e = {description = {' Bookmarks SPC f m'}, command = 'Telescope marks'},
f = {description = {' Load Last Session SPC s l'}, command = 'SessionLoad'} f = {description = {' Load Last Session SPC s l'}, command = 'SessionLoad'}
} }
vim.g.dashboard_custom_header = { vim.g.dashboard_custom_header = {

View File

@ -0,0 +1,40 @@
return require('gitsigns').setup {
signs = {
add = {hl = 'DiffAdd' , text = '', numhl='GitSignsAddNr'},
change = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'},
delete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'},
topdelete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'},
changedelete = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'}
},
numhl = true,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
['n ]c'] = { expr = true, '&diff ? \']c\' : \'<cmd>lua require"gitsigns.actions".next_hunk()<CR>\''},
['n [c'] = { expr = true, '&diff ? \'[c\' : \'<cmd>lua require"gitsigns.actions".prev_hunk()<CR>\''},
['n <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['v <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>gu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['v <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>gR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
['n <leader>gp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>'
},
watch_index = {
interval = 1000,
follow_files = true
},
current_line_blame = false,
current_line_blame_delay = 1000,
current_line_blame_position = 'eol',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
word_diff = false,
use_decoration_api = true,
use_internal_diff = true -- If luajit is present
}

View File

@ -174,28 +174,37 @@ gls.right[5] = {
} }
gls.right[6] = { gls.right[6] = {
DiffAdd = { GitSeparator = {
provider = 'DiffAdd', provider = function()
condition = condition.hide_in_width, return ' '
icon = '', end,
highlight = {colors.green, colors.grey1} highlight = {colors.green, colors.grey1}
} }
} }
gls.right[7] = { gls.right[7] = {
DiffModified = { DiffAdd = {
provider = 'DiffModified', provider = 'DiffAdd',
condition = condition.hide_in_width, condition = condition.hide_in_width,
icon = ' ', icon = ' ',
highlight = {colors.yellow, colors.grey1} highlight = {colors.green, colors.grey1}
} }
} }
gls.right[8] = { gls.right[8] = {
DiffModified = {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.yellow, colors.grey1}
}
}
gls.right[9] = {
DiffRemove = { DiffRemove = {
provider = 'DiffRemove', provider = 'DiffRemove',
condition = condition.hide_in_width, condition = condition.hide_in_width,
icon = '', icon = '',
highlight = {colors.red, colors.grey1} highlight = {colors.red, colors.grey1}
} }
} }
@ -211,7 +220,7 @@ gls.short_line_left[1] = {
gls.short_line_left[2] = { gls.short_line_left[2] = {
SFileName = { SFileName = {
provider = 'SFileName', provider = 'SFileName',
condition = condition.buffer_not_empty, condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1, 'bold'} highlight = {colors.fg, colors.grey1, 'bold'}
} }

View File

@ -10,6 +10,35 @@ local function tree_options()
vim.g.nvim_tree_auto_resize = 0 vim.g.nvim_tree_auto_resize = 0
-- vim.g.nvim_tree_add_trailing = 1 -- vim.g.nvim_tree_add_trailing = 1
vim.g.nvim_tree_lsp_diagnostics = 1 vim.g.nvim_tree_lsp_diagnostics = 1
vim.g.nvim_tree_icons = {
default = '',
symlink = '',
git = {
unstaged = "U",
staged = "S",
unmerged = "",
renamed = "R",
untracked = "",
deleted = "D",
ignored = "I"
},
folder = {
arrow_open = "",
arrow_closed = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = ""
},
lsp = {
hint = "",
info = "",
warning = "",
error = ""
}
}
end end
tree_options() tree_options()

View File

@ -6,8 +6,6 @@ local function load_options()
vim.cmd('set iskeyword+=-') vim.cmd('set iskeyword+=-')
-- General settings -- General settings
opt.termguicolors = true
-- opt.background = 'dark'
opt.mouse = 'a' opt.mouse = 'a'
opt.errorbells = false opt.errorbells = false
opt.visualbell = false opt.visualbell = false
@ -102,7 +100,7 @@ local function load_options()
opt.signcolumn = 'yes' opt.signcolumn = 'yes'
opt.number = true opt.number = true
opt.relativenumber = true opt.relativenumber = true
opt.numberwidth = 4 -- opt.numberwidth = 6
-- 4 spaces = 1 tab -- 4 spaces = 1 tab
opt.tabstop = 4 opt.tabstop = 4

View File

@ -52,6 +52,15 @@ return packer.startup(
end end
} }
-- Git
use {
'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function()
require('modules.gitgutter')
end
}
-- LSP -- LSP
end end
) )