diff --git a/home/.config/nu/config.toml b/home/.config/nu/config.toml index eb498cd..6f85737 100644 --- a/home/.config/nu/config.toml +++ b/home/.config/nu/config.toml @@ -1,9 +1,12 @@ skip_welcome_message = true -prompt = "__zoxide_hook; starship prompt" startup = [ - "zoxide init nushell --hook prompt | save ~/.local/share/nu/zoxide.nu", - "source ~/.local/share/nu/zoxide.nu" - ] + "mkdir ~/.cache/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] completion_type = "list" diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 3b6c39e..f7f50c5 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -9,7 +9,7 @@ local disable_distribution_plugins = function() vim.g.loaded_vimball = 1 vim.g.loaded_vimballPlugin = 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_logiPat = 1 vim.g.loaded_rrhelper = 1 @@ -31,11 +31,12 @@ local load_core = function() -- Config require('options') + require('colors.' .. vim.g.global_theme).highlight() disable_distribution_plugins() leader_map() require('plugins') - require('colors.' .. vim.g.global_theme).highlight() require('events').load_autocmds() + require('mappings') end load_core() diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 480aa10..49fef47 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -1,18 +1,17 @@ -local api = vim.api local M = {} local function hi(group, guifg, guibg, attr, guisp) if guifg ~= '' then - api.nvim_command('hi ' .. group .. ' guifg=' .. guifg) + vim.cmd('hi ' .. group .. ' guifg=' .. guifg) end if guibg ~= '' then - api.nvim_command('hi ' .. group .. ' guibg=' .. guibg) + vim.cmd('hi ' .. group .. ' guibg=' .. guibg) end if attr ~= '' then - api.nvim_command('hi ' .. group .. ' gui=' .. attr) + vim.cmd('hi ' .. group .. ' gui=' .. attr) end if guisp ~= '' then - api.nvim_command('hi ' .. group .. ' guisp=' .. guisp) + vim.cmd('hi ' .. group .. ' guisp=' .. guisp) end end @@ -38,8 +37,166 @@ M.colors = { none = 'NONE' } +local c = M.colors + 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 return M diff --git a/home/.config/nvim/lua/colors/onedark.lua b/home/.config/nvim/lua/colors/onedark.lua index 2196a9d..6228f71 100644 --- a/home/.config/nvim/lua/colors/onedark.lua +++ b/home/.config/nvim/lua/colors/onedark.lua @@ -1,18 +1,17 @@ -local api = vim.api local M = {} local function hi(group, guifg, guibg, attr, guisp) if guifg ~= '' then - api.nvim_command('hi ' .. group .. ' guifg=' .. guifg) + vim.cmd('hi ' .. group .. ' guifg=' .. guifg) end if guibg ~= '' then - api.nvim_command('hi ' .. group .. ' guibg=' .. guibg) + vim.cmd('hi ' .. group .. ' guibg=' .. guibg) end if attr ~= '' then - api.nvim_command('hi ' .. group .. ' gui=' .. attr) + vim.cmd('hi ' .. group .. ' gui=' .. attr) end if guisp ~= '' then - api.nvim_command('hi ' .. group .. ' guisp=' .. guisp) + vim.cmd('hi ' .. group .. ' guisp=' .. guisp) end end @@ -39,8 +38,10 @@ M.colors = { none = 'NONE' } +local c = M.colors + function M.highlight() - hi('ModeMsg', M.colors.green, '', '', '') + hi('ModeMsg', c.green, '', '', '') end return M diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..188fa74 --- /dev/null +++ b/home/.config/nvim/lua/mappings.lua @@ -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', [[]], opt) + +-- Better Y +map('n', 'Y', [[y$]], opt) + +-- Continuous indent +map('v', '<', '', '>gv', opt) + +-- Escape mode in terminal buffer +map('t', '', '', opt) + +-- Copy the whole buffer +map('n', '', [[ %y+]], opt) +-- 'Legacy' save file +-- map('n', '', ':w ', opt) +-- Close buffer +map('n', '', ':bd!', opt) + +-- Remove trailing whitespace +map('n', '', ':%s/\\s\\+$//e', opt) + +-- Resize buffer +map('n', '', ':resize -2', opt) +map('n', '', ':resize +2', opt) +map('n', '', ':vertical resize -2', opt) +map('n', '', ':vertical resize +2', 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', '', ':lua toggleIndentStyle()', opt) + +----------------------- +-- Plugins' bindings -- +----------------------- +-- Move between tabs +map('n', '', [[BufferLineCycleNext]], opt) +map('n', '', [[BufferLineCyclePrev]], opt) + +-- NvimTree +map('n', '', ':NvimTreeToggle', opt) diff --git a/home/.config/nvim/lua/modules/bufferline.lua b/home/.config/nvim/lua/modules/bufferline.lua index 746a048..376b08b 100644 --- a/home/.config/nvim/lua/modules/bufferline.lua +++ b/home/.config/nvim/lua/modules/bufferline.lua @@ -1,14 +1,30 @@ return require('bufferline').setup { options = { + numbers = 'none', mappings = true, - max_name_length = 18, - max_prefix_length = 16, - tab_size = 18, + max_name_length = 16, + max_prefix_length = 14, + tab_size = 20, diagnostics = 'nvim_lsp', + show_close_icon = false, + show_buffer_icons = true, show_tab_indicators = true, enforce_regular_tabs = false, show_buffer_close_icons = true, always_show_bufferline = true, + offsets = { + {filetype = 'NvimTree', text = 'NvimTree', text_align = 'left'}, + {filetype = 'packer', text = 'Packer', text_align = 'left'} + }, separator_style = 'thin' + }, + + highlights = { + fill = { + guibg = { + attribute = 'bg', + highlight = 'TabLineFill' + } + } } } diff --git a/home/.config/nvim/lua/modules/dashboard.lua b/home/.config/nvim/lua/modules/dashboard.lua index 5f3e176..b99b372 100644 --- a/home/.config/nvim/lua/modules/dashboard.lua +++ b/home/.config/nvim/lua/modules/dashboard.lua @@ -9,8 +9,8 @@ local function dashboard_options() 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'}, - d = {description = {'洛 New File SPC f n'}, command = 'DashboardNewFile'}, - e = {description = {' Bookmarks SPC b m'}, command = 'Telescope marks'}, + d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'}, + e = {description = {' Bookmarks SPC f m'}, command = 'Telescope marks'}, f = {description = {' Load Last Session SPC s l'}, command = 'SessionLoad'} } vim.g.dashboard_custom_header = { diff --git a/home/.config/nvim/lua/modules/gitgutter.lua b/home/.config/nvim/lua/modules/gitgutter.lua new file mode 100644 index 0000000..b545f5a --- /dev/null +++ b/home/.config/nvim/lua/modules/gitgutter.lua @@ -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\' : \'lua require"gitsigns.actions".next_hunk()\''}, + ['n [c'] = { expr = true, '&diff ? \'[c\' : \'lua require"gitsigns.actions".prev_hunk()\''}, + + ['n gs'] = 'lua require"gitsigns".stage_hunk()', + ['v gs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n gu'] = 'lua require"gitsigns".undo_stage_hunk()', + ['n gr'] = 'lua require"gitsigns".reset_hunk()', + ['v gr'] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n gR'] = 'lua require"gitsigns".reset_buffer()', + ['n gp'] = 'lua require"gitsigns".preview_hunk()', + ['n gb'] = 'lua require"gitsigns".blame_line(true)' + }, + watch_index = { + interval = 1000, + follow_files = true + }, + current_line_blame = false, + current_line_blame_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 +} diff --git a/home/.config/nvim/lua/modules/statusline.lua b/home/.config/nvim/lua/modules/statusline.lua index 69bea26..2daf4da 100644 --- a/home/.config/nvim/lua/modules/statusline.lua +++ b/home/.config/nvim/lua/modules/statusline.lua @@ -174,28 +174,37 @@ gls.right[5] = { } gls.right[6] = { - DiffAdd = { - provider = 'DiffAdd', - condition = condition.hide_in_width, - icon = '  ', + GitSeparator = { + provider = function() + return ' ' + end, highlight = {colors.green, colors.grey1} } } gls.right[7] = { - DiffModified = { - provider = 'DiffModified', + DiffAdd = { + provider = 'DiffAdd', condition = condition.hide_in_width, - icon = ' 柳', - highlight = {colors.yellow, colors.grey1} + icon = ' ', + highlight = {colors.green, colors.grey1} } } gls.right[8] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = '柳', + highlight = {colors.yellow, colors.grey1} + } +} + +gls.right[9] = { DiffRemove = { provider = 'DiffRemove', condition = condition.hide_in_width, - icon = '  ', + icon = ' ', highlight = {colors.red, colors.grey1} } } @@ -211,7 +220,7 @@ gls.short_line_left[1] = { gls.short_line_left[2] = { SFileName = { - provider = 'SFileName', + provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.fg, colors.grey1, 'bold'} } diff --git a/home/.config/nvim/lua/modules/tree.lua b/home/.config/nvim/lua/modules/tree.lua index 7e55d91..cb37cbc 100644 --- a/home/.config/nvim/lua/modules/tree.lua +++ b/home/.config/nvim/lua/modules/tree.lua @@ -10,6 +10,35 @@ local function tree_options() vim.g.nvim_tree_auto_resize = 0 -- vim.g.nvim_tree_add_trailing = 1 vim.g.nvim_tree_lsp_diagnostics = 1 + vim.g.nvim_tree_icons = { + default = '', + symlink = '', + git = { + unstaged = "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 tree_options() diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 2fcbc81..288b5c0 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -6,8 +6,6 @@ local function load_options() vim.cmd('set iskeyword+=-') -- General settings - opt.termguicolors = true - -- opt.background = 'dark' opt.mouse = 'a' opt.errorbells = false opt.visualbell = false @@ -102,7 +100,7 @@ local function load_options() opt.signcolumn = 'yes' opt.number = true opt.relativenumber = true - opt.numberwidth = 4 + -- opt.numberwidth = 6 -- 4 spaces = 1 tab opt.tabstop = 4 diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 71b6859..3ef8cfa 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -52,6 +52,15 @@ return packer.startup( end } + -- Git + use { + 'lewis6991/gitsigns.nvim', + requires = 'nvim-lua/plenary.nvim', + config = function() + require('modules.gitgutter') + end + } + -- LSP end )