diff --git a/fzf-marks b/fzf-marks index ac061af..128d505 100644 --- a/fzf-marks +++ b/fzf-marks @@ -6,16 +6,16 @@ lfview : /home/corpse/.local/bin/lfview gtk2 : /home/corpse/.config/gtk-2.0/gtkrc-2.0 dunst : /home/corpse/.config/dunst/dunstrc xresources : /home/corpse/.config/X11/xresources -polybar : /home/corpse/.config/polybar/config correo : /home/corpse/.config/neomutt xinit : /home/corpse/.config/X11/xinitrc -bspwm : /home/corpse/.config/bspwm/bspwmrc terminal : /home/corpse/.config/alacritty.yml tmux : /home/corpse/.config/tmux/tmux.conf -keys : /home/corpse/.config/sxhkd/sxhkdrc -lf : /home/corpse/.config/lf/lfrc alias : /home/corpse/.config/zsh/conf/03_aliases.zsh +mpv : /home/corpse/.config/mpv/mpv.conf +lf : /home/corpse/.config/lf/lfrc zshenv : /home/corpse/.zshenv +polybar : /home/corpse/.config/polybar/config +keys : /home/corpse/.config/sxhkd/sxhkdrc +bspwm : /home/corpse/.config/bspwm/bspwmrc nvim : /home/corpse/.config/nvim zsh : /home/corpse/.config/zsh -mpv : /home/corpse/.config/mpv/mpv.conf diff --git a/gtk-3.0/settings.ini b/gtk-3.0/settings.ini index 66f110f..ae04df5 100644 --- a/gtk-3.0/settings.ini +++ b/gtk-3.0/settings.ini @@ -1,5 +1,6 @@ [Settings] gtk-application-prefer-dark-theme=1 +gtk-cursor-theme-name=Grounation gtk-theme-name=Skeuos-Black-Dark gtk-icon-theme-name=BluecurveRH gtk-font-name=System Charcoal 10 @@ -16,4 +17,3 @@ gtk-xft-hintstyle=hintslight gtk-xft-rgba=rgb gtk-modules=gail:atk-bridge gtk-decoration-layout=menu: -gtk-cursor-theme-name=Grounation diff --git a/lf/lfrc b/lf/lfrc index 3c3e315..d5446b8 100644 --- a/lf/lfrc +++ b/lf/lfrc @@ -16,6 +16,7 @@ set preview set previewer lfview set ratios 2:4 set icons +recol %[ $LF_LEVEL -eq 1 ] || echo "Warning: You're in a nested lf instance!" @@ -33,6 +34,17 @@ cmd open ${{ esac }} +cmd recol &{{ + w=$(tput cols) + if [ $w -le 80 ]; then + lf -remote "send $id set ratios 1:1" + elif [ $w -le 160 ]; then + lf -remote "send $id set ratios 2:2" + else + lf -remote "send $id set ratios 2:4" + fi +}} + cmd bulkrename ${{ old=$(mktemp) new=$(mktemp) @@ -98,42 +110,32 @@ cmd rename-new &{{ }} cmd paste-rsync &{{ - load=$(lf -remote 'load') - mode=$(echo "$load" | sed -n '1p') - list=$(echo "$load" | sed '1d') - - if [ $mode = 'copy']; then - rsync -av --ignore-existing --progress $list . \ - | stdbuf -i0 -o0 -e0 tr '\r' '\n' \ - | while read line; do - lf -remote "send $id echo $line" - done - elif [ $mode = 'move' ]; then - mv -n $list . - fi - - lf -remote 'send load' - lf -remote 'send clear' + set -- $(cat ~/.local/share/lf/files) + mode="$1" + shift + case "$mode" in + copy) + rsync -av --ignore-existing --progress -- "$@" . | + stdbuf -i0 -o0 -e0 tr '\r' '\n' | + while IFS= read -r line; do + lf -remote "send $id echo $line" + done + ;; + move) mv -n -- "$@" .;; + esac + rm ~/.local/share/lf/files + lf -remote "send clear" }} cmd paste-overwrite %{{ - set -f - load=$(lf -remote "load") - mode=$(echo "$load" | head -1) - list=$(echo "$load" | sed '1d') - set -- _ $list; shift - [ $# -gt 0 ] || exit - case $mode in - copy) - rsync -r "$@" ./ - ;; - move) - rsync -r --remove-source-files "$@" ./ - ;; - esac - lf -remote 'save\nmove\n' - lf -remote "send $id load" - lf -remote "send $id echo \"\033[0;32mpasted $# file(s)\033[0m\"" + mode=$(head -1 ~/.local/share/lf/files) + list=$(sed 1d ~/.local/share/lf/files) + if [ $mode = 'copy' ]; then + cp -r $list . + elif [ $mode = 'move' ]; then + mv $list . + fi + lf -remote 'send clear' }} cmd fzf_jump ${{ diff --git a/nvim/init.lua b/nvim/init.lua index 63704f1..e557639 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,63 +1,85 @@ -vim.g.mapleader = ' ' -vim.g.maplocalleader = ',' +vim.g.mapleader = " " +vim.g.maplocalleader = "," vim.o.termguicolors = true -local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' +local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) + vim.fn.execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) end -require('packer').startup({function(use) - use 'wbthomason/packer.nvim' - use({ 'lewis6991/impatient.nvim', - config = function() - require('impatient') - end -}) -use { 'nathom/filetype.nvim' } -use { 'neovim/nvim-lspconfig', requires = {'ray-x/lsp_signature.nvim'}, config = [[ require('plugins/lspconfig') ]] } -use { 'hrsh7th/nvim-cmp', -requires = { - 'hrsh7th/cmp-nvim-lsp', - "hrsh7th/cmp-nvim-lua", - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'saadparwaiz1/cmp_luasnip', -}, -config = [[ require('plugins/cmp') ]], - } - use { 'L3MON4D3/LuaSnip', requires = { 'rafamadriz/friendly-snippets', }} - use { 'windwp/nvim-autopairs', config = [[ require('plugins/autopairs') ]] } - use { 'nvim-telescope/telescope.nvim', - requires = { - {'nvim-lua/plenary.nvim', opt = true,}, - {'nvim-telescope/telescope-fzf-native.nvim', opt = true, run = 'make' } - }, - config = [[ require('plugins/telescope') ]], -} -use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = [[ require('plugins/treesitter') ]] } -use { 'ellisonleao/gruvbox.nvim', requires = {'rktjmp/lush.nvim', opt = true}, } -use { 'kyazdani42/nvim-web-devicons', after = 'gruvbox.nvim', opt =true, config = [[ require('plugins/webdevicons_nvim') ]] } -use { 'numToStr/Comment.nvim', require('Comment').setup() } -use { 'norcalli/nvim-colorizer.lua', config = [[ require('plugins/colorizer') ]] } -use { 'tpope/vim-fugitive', opt = true, cmd = { "Git", "Gdiff", "Gblame", "Glog", "Git mergetool" }, } -use { 'lewis6991/gitsigns.nvim', event = { "BufRead", "BufNewFile" }, requires = { 'nvim-lua/plenary.nvim', opt = true, }, config = [[ require('plugins/gitsigns_nvim') ]] } -use { - 'folke/lsp-trouble.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - config = function() - require("trouble").setup() +require("packer").startup({ + function(use) + use("wbthomason/packer.nvim") + use({ + "lewis6991/impatient.nvim", + config = function() + require("impatient") + end, + }) + use({ "nathom/filetype.nvim" }) + use({ + "neovim/nvim-lspconfig", + requires = { "ray-x/lsp_signature.nvim" }, + config = [[ require('plugins/lspconfig') ]], + }) + use({ + "hrsh7th/nvim-cmp", + requires = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + config = [[ require('plugins/cmp') ]], + }) + use({ "L3MON4D3/LuaSnip", requires = { "rafamadriz/friendly-snippets" } }) + use({ "windwp/nvim-autopairs", config = [[ require('plugins/autopairs') ]] }) + use({ + "nvim-telescope/telescope.nvim", + requires = { + { "nvim-lua/plenary.nvim", opt = true }, + { "nvim-telescope/telescope-fzf-native.nvim", opt = true, run = "make" }, + }, + config = [[ require('plugins/telescope') ]], + }) + use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", config = [[ require('plugins/treesitter') ]] }) + use({ "ellisonleao/gruvbox.nvim", requires = { "rktjmp/lush.nvim", opt = true } }) + use({ + "kyazdani42/nvim-web-devicons", + after = "gruvbox.nvim", + opt = true, + config = [[ require('plugins/webdevicons_nvim') ]], + }) + use({ "numToStr/Comment.nvim", require("Comment").setup() }) + use({ "norcalli/nvim-colorizer.lua", config = [[ require('plugins/colorizer') ]] }) + use({ "tpope/vim-fugitive", opt = true, cmd = { "Git", "Gdiff", "Gblame", "Glog", "Git mergetool" } }) + use({ + "lewis6991/gitsigns.nvim", + event = { "BufRead", "BufNewFile" }, + requires = { "nvim-lua/plenary.nvim", opt = true }, + config = [[ require('plugins/gitsigns_nvim') ]], + }) + use({ + "folke/lsp-trouble.nvim", + requires = { "kyazdani42/nvim-web-devicons", opt = true }, + config = [[ require('plugins/trouble) ]], + cmd = { "LspTrouble" }, + }) + use({ + "jose-elias-alvarez/null-ls.nvim", + requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + config = [[ require('plugins/nulls') ]], + }) end, - cmd = { "LspTrouble" }, -} -use({ 'jose-elias-alvarez/null-ls.nvim', requires = {'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig'}, config = [[ require('plugins/nulls') ]] }) -end, -config = { - compile_path = vim.fn.stdpath('config')..'/lua/packer_compiled.lua', - display = { - open_fn = function() - return require('packer.util').float({ border = 'single' }) - end - } -}}) -require('packer_compiled') + config = { + compile_path = vim.fn.stdpath("config") .. "/lua/packer_compiled.lua", + display = { + open_fn = function() + return require("packer.util").float({ border = "single" }) + end, + }, + }, +}) +require("packer_compiled") vim.g.did_load_filetypes = 1 diff --git a/nvim/lua/plugins/autopairs.lua b/nvim/lua/plugins/autopairs.lua index 767939a..fb4d9d3 100644 --- a/nvim/lua/plugins/autopairs.lua +++ b/nvim/lua/plugins/autopairs.lua @@ -1,55 +1,51 @@ -require('nvim-autopairs').setup({ +require("nvim-autopairs").setup({ check_ts = true, ts_config = { - lua = {'string'},-- it will not add pair on that treesitter node - javascript = {'template_string'}, + lua = { "string" }, -- it will not add pair on that treesitter node + javascript = { "template_string" }, + }, + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "Search", + highlight_grey = "Comment", }, - enable_check_bracket_line = true, -- Don't add pairs if it already have a close pairs in same line - disable_filetype = { "TelescopePrompt" , "vim" }, -- - enable_afterquote = false, -- add bracket pairs after quote - enable_moveright = true }) -local Rule = require('nvim-autopairs.rule') -require('nvim-autopairs').add_rules({ - Rule("%", "%", "lua") - :with_pair(require('nvim-autopairs.ts-conds').is_ts_node({'string','comment'})), - Rule("$", "$", "lua") - :with_pair(require('nvim-autopairs.ts-conds').is_not_ts_node({'function'})), - Rule(' ', ' ') - :with_pair(function (opts) - local pair = opts.line:sub(opts.col - 1, opts.col) - return vim.tbl_contains({ '()', '[]', '{}' }, pair) - end), - Rule('( ', ' )') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%)') ~= nil - end) - :use_key(')'), - Rule('{ ', ' }') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%}') ~= nil - end) - :use_key('}'), - Rule('[ ', ' ]') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%]') ~= nil - end) - :use_key(']'), - Rule('%(.*%)%s*%=>$', ' { }', { 'typescript', 'typescriptreact', 'javascript' }) - :use_regex(true) - :set_end_pair_length(2), -}) +local Rule = require("nvim-autopairs.rule") -require("cmp").setup({ - map_complete = true, -- it will auto insert `(` (map_char) after select function or method item - auto_select = true, -- automatically select the first item - insert = false, -- use insert confirm behavior instead of replace - map_char = { -- modifies the function or method delimiter by filetypes - all = '(', - tex = '{' - } +require("nvim-autopairs").add_rules({ + Rule(" ", " "):with_pair(function(opts) + local pair = opts.line:sub(opts.col - 1, opts.col) + return vim.tbl_contains({ "()", "[]", "{}" }, pair) + end), + Rule("( ", " )") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%)") ~= nil + end) + :use_key(")"), + Rule("{ ", " }") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%}") ~= nil + end) + :use_key("}"), + Rule("[ ", " ]") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%]") ~= nil + end) + :use_key("]"), }) diff --git a/nvim/lua/plugins/cmp.lua b/nvim/lua/plugins/cmp.lua index 03df3f1..7b62c7f 100644 --- a/nvim/lua/plugins/cmp.lua +++ b/nvim/lua/plugins/cmp.lua @@ -14,42 +14,42 @@ cmp.setup({ formatting = { format = function(entry, vim_item) vim_item.menu = ({ - nvim_lsp = '[LSP]', - buffer = '[Buffer]', - luasnip = '[Snippet]', - nvim_lua = '[API]', - path = '[Path]', - spell = '[Spell]', + nvim_lsp = "[LSP]", + buffer = "[Buffer]", + luasnip = "[Snippet]", + nvim_lua = "[API]", + path = "[Path]", + spell = "[Spell]", })[entry.source.name] vim_item.kind = ({ - Text = ' text', - Method = ' Method', - Function = ' Function', - Constructor = ' Constructor', - Field = 'ﰠ Field', - Variable = ' Variable', - Class = ' Class', - Interface = 'ﰮ Interface', - Module = ' Module', - Property = ' Property', - Unit = ' Unit', - Value = ' Value', - Enum = ' Enum', - Keyword = ' Keyword', - Snippet = '﬌ Snippet', - Color = ' Color', - File = ' File', - Reference = ' Reference', - Folder = ' Folder', - EnumMember = ' EnumMember', - Constant = ' Constant', - Struct = ' Struct', - Event = ' Event', - Operator = ' Operator', - TypeParameter = ' TypeParameter', + Text = " text", + Method = " Method", + Function = " Function", + Constructor = " Constructor", + Field = "ﰠ Field", + Variable = " Variable", + Class = " Class", + Interface = "ﰮ Interface", + Module = " Module", + Property = " Property", + Unit = " Unit", + Value = " Value", + Enum = " Enum", + Keyword = " Keyword", + Snippet = "﬌ Snippet", + Color = " Color", + File = " File", + Reference = " Reference", + Folder = " Folder", + EnumMember = " EnumMember", + Constant = " Constant", + Struct = " Struct", + Event = " Event", + Operator = " Operator", + TypeParameter = " TypeParameter", })[vim_item.kind] return vim_item - end + end, }, snippet = { expand = function(args) @@ -57,52 +57,50 @@ cmp.setup({ end, }, mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping(function(_) return vim.fn.pumvisible() == 1 and cmp.close() or cmp.complete() end), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm { select = true,}, + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip and luasnip.expand_or_jumpable() then luasnip.expand_or_jump() elseif has_words_before() then - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes("", true, true, true), - "n", - true - ) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, true, true), "n", true) else fallback() end - end, { "i", "s" }), + end, { + "i", + "s", + }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip and luasnip.jumpable(-1) then luasnip.jump(-1) elseif has_words_before() then - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes("", true, true, true), - "n", - true - ) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, true, true), "n", true) else fallback() end - end, { "i", "s" }), + end, { + "i", + "s", + }), }, preselect = cmp.PreselectMode.Item, sources = { - { name = 'path' }, - { name = 'buffer', Keyword_length = 5 }, + { name = "path" }, + { name = "buffer", Keyword_length = 5 }, }, - experimental = { native_menu = false } + experimental = { native_menu = false }, }) local cmp_autopairs = require("nvim-autopairs.completion.cmp") diff --git a/nvim/lua/plugins/colorizer.lua b/nvim/lua/plugins/colorizer.lua index 6cc5329..ab298af 100644 --- a/nvim/lua/plugins/colorizer.lua +++ b/nvim/lua/plugins/colorizer.lua @@ -1,14 +1,13 @@ -require 'colorizer'.setup ({ - 'css'; - 'html'; - 'javascript'; - 'javascriptreact'; - 'typescript'; - 'typescriptreact'; - 'vim'; - 'yaml'; - 'python'; -}, -{ - names = false; +require("colorizer").setup({ + "css", + "html", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vim", + "yaml", + "python", +}, { + names = false, }) diff --git a/nvim/lua/plugins/gitsigns_nvim.lua b/nvim/lua/plugins/gitsigns_nvim.lua index 5cf3124..5fb7747 100644 --- a/nvim/lua/plugins/gitsigns_nvim.lua +++ b/nvim/lua/plugins/gitsigns_nvim.lua @@ -1,35 +1,35 @@ if not packer_plugins["plenary.nvim"].loaded then - vim.cmd([[packadd plenary.nvim]]) + vim.cmd([[packadd plenary.nvim]]) end -require('gitsigns').setup { +require("gitsigns").setup({ signcolumn = true, - current_line_blame_opts = { delay = 2000, virt_text_pos = 'right_align' }, + current_line_blame_opts = { delay = 2000, virt_text_pos = "right_align" }, signs = { - add = {hl = 'GitSignsAdd' , text = '┃', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '┃', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '╏', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '┯', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '╍', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + add = { hl = "GitSignsAdd", text = "┃", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "┃", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "╏", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "┯", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "╍", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, }, update_debounce = 200, use_internal_diff = true, keymaps = { noremap = true, - ['n }g'] = { expr = true, "&diff ? '}c' : 'lua require\"gitsigns\".next_hunk()'"}, - ['n {g'] = { expr = true, "&diff ? '{c' : 'lua require\"gitsigns\".prev_hunk()'"}, - } -} + ["n }g"] = { expr = true, "&diff ? '}c' : 'lua require\"gitsigns\".next_hunk()'" }, + ["n {g"] = { expr = true, "&diff ? '{c' : 'lua require\"gitsigns\".prev_hunk()'" }, + }, +}) vim.g.fugitive_summary_format = "%an\t%s" local map = vim.api.nvim_set_keymap -local default_opts = {noremap = true, silent = true} +local default_opts = { noremap = true, silent = true } -map('n', 'tt', ':Gitsigns toggle_signs', default_opts) -map('n', 'tb', ':Gitsigns toggle_current_line_blame', default_opts) -map('n', 'ff', ':G', default_opts) -map('n', 'fc', ':GCheckout', default_opts) -map('n', 'fd', ':Gvdiffsplit!', default_opts) -map('n', 'fh', ':diffget //2', default_opts) -map('n', 'fl', ':diffget //3', default_opts) +map("n", "tt", ":Gitsigns toggle_signs", default_opts) +map("n", "tb", ":Gitsigns toggle_current_line_blame", default_opts) +map("n", "ff", ":G", default_opts) +map("n", "fc", ":GCheckout", default_opts) +map("n", "fd", ":Gvdiffsplit!", default_opts) +map("n", "fh", ":diffget //2", default_opts) +map("n", "fl", ":diffget //3", default_opts) diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 8c58aae..e198f5e 100644 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -11,15 +11,9 @@ sign define LspDiagnosticsSignHint text= texthl=LspDiagnosticsSignHint linehl ]]) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - underline = true, - signs = true, update_in_insert = true, severity_sort = true, - virtual_text = { - spacing = 5, - severity_limit = "Hint", - source = "always", - }, + virtual_text = false, }) local nvim_lsp = require("lspconfig") @@ -33,13 +27,6 @@ local on_attach = function(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, "n", "rn", "lua vim.lsp.buf.rename()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "lua vim.lsp.buf.code_action()", opts) - vim.api.nvim_buf_set_keymap( - bufnr, - "n", - "e", - "lua vim.lsp.diagnostic.show_line_diagnostics()", - opts - ) vim.api.nvim_buf_set_keymap(bufnr, "n", "}d", "lua vim.lsp.diagnostic.goto_next()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", "lua vim.lsp.diagnostic.set_loclist()", opts) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { @@ -48,10 +35,7 @@ local on_attach = function(client, bufnr) require("lsp_signature").on_attach({ bind = true, hint_prefix = " ", - hi_parameter = "ModeMsg", - transparency = 80, - trigger_on_newline = false, - toggle_key = "", + handler_opts = { border = "rounded" }, }) if client.resolved_capabilities.document_formatting then vim.cmd("autocmd BufWritePre lua vim.lsp.buf.formatting_sync()") @@ -65,15 +49,8 @@ require("lspconfig/configs").ls_emmet = { "html", "css", "scss", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "haml", "xml", "xsl", - "pug", - "slim", "sass", "stylus", "less", diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 484ce54..0c9004a 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,31 +1,31 @@ vim.cmd([[packadd plenary.nvim]]) vim.cmd([[packadd telescope-fzf-native.nvim]]) -local actions = require('telescope.actions') -local previewers = require('telescope.previewers') -local Job = require('plenary.job') +local actions = require("telescope.actions") +local previewers = require("telescope.previewers") +local Job = require("plenary.job") local new_maker = function(filepath, bufnr, opts) filepath = vim.fn.expand(filepath) Job - :new({ - command = 'file', - args = { '--mime-type', '-b', filepath }, - on_exit = function(j) - local mime_type = vim.split(j:result()[1], '/')[1] - if mime_type == 'text' then - previewers.buffer_previewer_maker(filepath, bufnr, opts) - else - vim.schedule(function() - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'BINARY' }) - end) - end - end, - }) - :sync() + :new({ + command = "file", + args = { "--mime-type", "-b", filepath }, + on_exit = function(j) + local mime_type = vim.split(j:result()[1], "/")[1] + if mime_type == "text" then + previewers.buffer_previewer_maker(filepath, bufnr, opts) + else + vim.schedule(function() + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" }) + end) + end + end, + }) + :sync() end -require('telescope').setup { +require("telescope").setup({ defaults = { prompt_title = " ", results_title = " ", @@ -40,69 +40,69 @@ require('telescope').setup { buffers = { mappings = { n = { - ['d'] = actions.delete_buffer, + ["d"] = actions.delete_buffer, }, }, sort_mru = true, preview_title = false, }, find_files = { - find_command = {'fd', '-t f', '-c always', '-H'}, + find_command = { "fd", "-t f", "-c always", "-H" }, hidden = true, }, file_browser = { hidden = true, }, lsp_references = { - initial_mode = 'normal', - sorting_strategy = 'ascending', - layout_strategy = 'cursor', + initial_mode = "normal", + sorting_strategy = "ascending", + layout_strategy = "cursor", preview_title = false, results_title = false, - prompt_title = 'References', + prompt_title = "References", layout_config = { width = 0.4, height = 0.4, }, }, lsp_code_actions = { - initial_mode = 'normal', - sorting_strategy = 'ascending', - layout_strategy = 'cursor', + initial_mode = "normal", + sorting_strategy = "ascending", + layout_strategy = "cursor", preview = false, - prompt_title = 'Code Actions', - results_title = '', + prompt_title = "Code Actions", + results_title = "", layout_config = { width = 0.2, height = 0.3, }, }, lsp_range_code_actions = { - initial_mode = 'normal', - sorting_strategy = 'ascending', - layout_strategy = 'cursor', + initial_mode = "normal", + sorting_strategy = "ascending", + layout_strategy = "cursor", preview = false, - prompt_title = 'Code Actions', - results_title = '', + prompt_title = "Code Actions", + results_title = "", layout_config = { width = 0.3, height = 0.3, }, }, lsp_document_diagnostics = { - initial_mode = 'normal', - sorting_strategy = 'ascending', - layout_strategy = 'cursor', - prompt_title = 'Diagnostics', - results_title = '', + initial_mode = "normal", + sorting_strategy = "ascending", + layout_strategy = "cursor", + prompt_title = "Diagnostics", + results_title = "", layout_config = { width = 0.5, height = 0.5, }, }, lsp_definitions = { - layout_strategy = 'cursor', - prompt_title = 'Definitions', + layout_strategy = "cursor", + prompt_title = "Definitions", preview_title = false, results_title = false, layout_config = { @@ -113,8 +113,8 @@ require('telescope').setup { }, selection_caret = "→", color_devicons = true, - file_ignore_patterns = { 'node_modules', '.git' }, - set_env = {['COLORTERM'] = 'truecolor'}, + file_ignore_patterns = { "node_modules", ".git" }, + set_env = { ["COLORTERM"] = "truecolor" }, buffer_previewer_maker = new_maker, mappings = { i = { @@ -126,18 +126,18 @@ require('telescope').setup { }, n = { [""] = actions.smart_send_to_qflist + actions.open_qflist, - } + }, }, - } -} -require('telescope').load_extension('fzf') + }, +}) +require("telescope").load_extension("fzf") local map = vim.api.nvim_set_keymap -local default_opts = {noremap = true, silent = true} -map('n', '', 'Telescope help_tags', default_opts) -map('n', '', 'lua require("telescope.builtin").find_files({cwd = "%:h", hidden=true})', default_opts) -map('n', '', 'Telescope file_browser hidden=true', default_opts) -map('n', '', 'Telescope buffers', default_opts) -map('n', '', 'Telescope live_grep', default_opts) -map('n', '', 'Telescope git_commits', default_opts) -map('n', '', 'Telescope resume', default_opts) +local default_opts = { noremap = true, silent = true } +map("n", "", "Telescope help_tags", default_opts) +map("n", "", 'lua require("telescope.builtin").find_files({cwd = "%:h", hidden=true})', default_opts) +map("n", "", "Telescope file_browser hidden=true", default_opts) +map("n", "", "Telescope buffers", default_opts) +map("n", "", "Telescope live_grep", default_opts) +map("n", "", "Telescope git_commits", default_opts) +map("n", "", "Telescope resume", default_opts) diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 2eeeacb..b40dd1f 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -1,26 +1,41 @@ -require'nvim-treesitter.configs'.setup { - ensure_installed = { "bash", "css", "go", "gomod", "html", "json", "json5", "jsonc", "lua", "regex", "scss", "toml", "vim", "yaml" }, +require("nvim-treesitter.configs").setup({ + ensure_installed = { + "bash", + "css", + "go", + "gomod", + "html", + "json", + "json5", + "jsonc", + "lua", + "regex", + "scss", + "toml", + "vim", + "yaml", + }, highlight = { enable = true, use_languagetree = true, additional_vim_regex_highlighting = false, }, - indent = { enable = true, }, + indent = { enable = true }, incremental_selection = { enable = true }, query_linter = { enable = true, use_virtual_text = true, - lint_events = { "BufWrite", "CursorHold" } + lint_events = { "BufWrite", "CursorHold" }, }, textobjects = { select = { enable = true, lookahead = true, keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", }, }, rainbow = { @@ -36,5 +51,5 @@ require'nvim-treesitter.configs'.setup { lua = "-- %s", }, }, - } -} + }, +}) diff --git a/nvim/lua/plugins/web-devicons.lua b/nvim/lua/plugins/web-devicons.lua index 3a269c5..b222568 100644 --- a/nvim/lua/plugins/web-devicons.lua +++ b/nvim/lua/plugins/web-devicons.lua @@ -2,91 +2,91 @@ local cmd = vim.cmd local M = {} function M.init() - cmd([[packadd nvim-web-devicons]]) - require("nvim-web-devicons").setup({ - override = { - html = { - icon = "", - color = "#DE8C92", - name = "html", - }, - css = { - icon = "", - color = "#61afef", - name = "css", - }, - js = { - icon = "", - color = "#EBCB8B", - name = "js", - }, - ts = { - icon = "ﯤ", - color = "#519ABA", - name = "ts", - }, - rs = { - icon = "", - color = "#FFAA30", - name = "rs", - }, - kt = { - icon = "󱈙", - color = "#ffcb91", - name = "kt", - }, - png = { - icon = " ", - color = "#BD77DC", - name = "png", - }, - jpg = { - icon = " ", - color = "#BD77DC", - name = "jpg", - }, - jpeg = { - icon = " ", - color = "#BD77DC", - name = "jpeg", - }, - mp3 = { - icon = "", - color = "#C8CCD4", - name = "mp3", - }, - mp4 = { - icon = "", - color = "#C8CCD4", - name = "mp4", - }, - out = { - icon = "", - color = "#C8CCD4", - name = "out", - }, - toml = { - icon = "", - color = "#61afef", - name = "toml", - }, - lock = { - icon = "", - color = "#DE6B74", - name = "lock", - }, - zip = { - icon = "", - color = "#EBCB8B", - name = "zip", - }, - xz = { - icon = "", - color = "#EBCB8B", - name = "xz", - }, - }, - }) + cmd([[packadd nvim-web-devicons]]) + require("nvim-web-devicons").setup({ + override = { + html = { + icon = "", + color = "#DE8C92", + name = "html", + }, + css = { + icon = "", + color = "#61afef", + name = "css", + }, + js = { + icon = "", + color = "#EBCB8B", + name = "js", + }, + ts = { + icon = "ﯤ", + color = "#519ABA", + name = "ts", + }, + rs = { + icon = "", + color = "#FFAA30", + name = "rs", + }, + kt = { + icon = "󱈙", + color = "#ffcb91", + name = "kt", + }, + png = { + icon = " ", + color = "#BD77DC", + name = "png", + }, + jpg = { + icon = " ", + color = "#BD77DC", + name = "jpg", + }, + jpeg = { + icon = " ", + color = "#BD77DC", + name = "jpeg", + }, + mp3 = { + icon = "", + color = "#C8CCD4", + name = "mp3", + }, + mp4 = { + icon = "", + color = "#C8CCD4", + name = "mp4", + }, + out = { + icon = "", + color = "#C8CCD4", + name = "out", + }, + toml = { + icon = "", + color = "#61afef", + name = "toml", + }, + lock = { + icon = "", + color = "#DE6B74", + name = "lock", + }, + zip = { + icon = "", + color = "#EBCB8B", + name = "zip", + }, + xz = { + icon = "", + color = "#EBCB8B", + name = "xz", + }, + }, + }) end return M diff --git a/nvim/lua/plugins/windline_nvim.lua b/nvim/lua/plugins/windline_nvim.lua deleted file mode 100644 index 42470d4..0000000 --- a/nvim/lua/plugins/windline_nvim.lua +++ /dev/null @@ -1,243 +0,0 @@ -local windline = require('windline') -local helper = require('windline.helpers') -local sep = helper.separators -local vim_components = require('windline.components.vim') -local b_components = require('windline.components.basic') -local state = _G.WindLine.state -local lsp_comps = require('windline.components.lsp') -local git_comps = require('windline.components.git') - -local hl_list = { - Black = { 'white', 'black' }, - White = { 'black', 'white' }, - Inactive = { 'InactiveFg', 'InactiveBg' }, - Active = { 'ActiveFg', 'ActiveBg' }, -} -local basic = {} - -basic.divider = { b_components.divider, '' } -basic.space = { ' ', '' } -basic.bg = { ' ', 'StatusLine' } -basic.file_name_inactive = { b_components.full_file_name, hl_list.Inactive } -basic.line_col_inactive = { b_components.line_col, hl_list.Inactive } -basic.progress_inactive = { b_components.progress, hl_list.Inactive } - -basic.vi_mode = { - hl_colors = { - Normal = { 'black', 'blue', 'bold' }, - Insert = { 'black', 'red', 'bold' }, - Visual = { 'black', 'white', 'bold' }, - Replace = { 'black', 'blue_light', 'bold' }, - Command = { 'black', 'magenta', 'bold' }, - NormalBefore = { 'blue', 'black' }, - InsertBefore = { 'red', 'black' }, - VisualBefore = { 'white', 'black' }, - ReplaceBefore = { 'blue_light', 'black' }, - CommandBefore = { 'magenta', 'black' }, - NormalAfter = { 'white', 'blue' }, - InsertAfter = { 'white', 'red' }, - VisualAfter = { 'white', 'white' }, - ReplaceAfter = { 'white', 'blue_light' }, - CommandAfter = { 'white', 'magenta' }, - }, - text = function() - return { - { sep.left_rounded, state.mode[2] .. 'Before' }, - { state.mode[1] .. ' ', state.mode[2] }, - } - end, -} - -basic.lsp_diagnos = { - width = 90, - hl_colors = { - red = { 'red', 'black' }, - yellow = { 'yellow', 'black' }, - blue = { 'blue', 'black' }, - }, - text = function() - if lsp_comps.check_lsp() then - return { - { lsp_comps.lsp_error({ format = '  %s' }), 'red' }, - { lsp_comps.lsp_warning({ format = '  %s' }), 'yellow' }, - { lsp_comps.lsp_hint({ format = '  %s' }), 'blue' }, - } - end - return '' - end, -} - -local icon_comp = b_components.cache_file_icon({ default = '', hl_colors = {'white','black_light'} }) - -basic.file = { - hl_colors = { - default = { 'white', 'black_light' }, - }, - text = function(bufnr) - return { - { ' ', 'default' }, - icon_comp(bufnr), - { ' ', 'default' }, - { b_components.cache_file_name('[No Name]', ''), '' }, - { b_components.file_modified(' '), '' }, - -- { b_components.cache_file_size(), '' }, - } - end, -} -basic.right = { - hl_colors = { - sep_before = { 'black_light', 'white_light' }, - sep_after = { 'white_light', 'black' }, - text = { 'black', 'white_light' }, - }, - text = function() - return { - -- { b_components.line_col, 'text' }, - { b_components.progress, 'text' }, - { sep.right_rounded, 'sep_after' }, - } - end, -} -basic.git = { - width = 90, - hl_colors = { - green = { 'green', 'black' }, - red = { 'red', 'black' }, - blue = { 'blue', 'black' }, - }, - text = function() - if git_comps.is_git() then - return { - { ' ', '' }, - { git_comps.diff_added({ format = '+%s' }), 'green' }, - { git_comps.diff_removed({ format = '-%s' }), 'red' }, - { git_comps.diff_changed({ format = '~%s' }), 'blue' }, - } - end - return '' - end, -} -basic.logo = { - hl_colors = { - sep_before = { 'blue', 'black' }, - default = { 'black', 'blue' }, - }, - text = function() - return { - { sep.left_rounded, 'sep_before' }, - { ' ', 'default' }, - } - end, -} --- LSP status -local lsp_status = require('lsp-status') -lsp_status.register_progress() -local lsp_config = require('lspconfig') - -- Lsp server name . -function lspservername() - local msg = '' - local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') - local clients = vim.lsp.get_active_clients() - if next(clients) == nil then return msg end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return "LSP[" .. client.name .. "]" - end - end - return msg -end - -basic.lsp = { - width = 90, - hl_colors = { - red = { 'red', 'black' }, - yellow = { 'yellow', 'black' }, - blue = { 'blue', 'black' }, - }, - text = function() - return { - { lsp_status.status, 'red' }, - {" ", ""}, - { lspservername(), 'red' }, - } - end, -} - -basic.git_branch = { - - text = function() - return { - { git_comps.git_branch(), { 'green', 'black', '' }, 90 }, - } - end, -} - -local default = { - filetypes = { 'default' }, - active = { - basic.vi_mode, - { git_comps.git_branch(), { 'red', 'black', 'bold' }, 90 }, - basic.git, - basic.file, - { vim_components.search_count(), { 'red', 'black_light' } }, - { sep.right_rounded, { 'black_light', 'black' } }, - basic.divider, - basic.lsp_diagnos, - basic.lsp, - { ' ', hl_list.Black }, - basic.right, - -- { ' ', hl_list.Black }, - }, - in_active = { - basic.file_name_inactive, - basic.divider, - basic.divider, - basic.line_col_inactive, - { '', { 'white', 'InactiveBg' } }, - basic.progress_inactive, - }, -} - -local quickfix = { - filetypes = { 'qf', 'Trouble' }, - active = { - { '🚦 Quickfix ', { 'white', 'black' } }, - { helper.separators.slant_right, { 'black', 'black_light' } }, - { - function() - return vim.fn.getqflist({ title = 0 }).title - end, - { 'cyan', 'black_light' }, - }, - { ' Total : %L ', { 'cyan', 'black_light' } }, - { helper.separators.slant_right, { 'black_light', 'InactiveBg' } }, - { ' ', { 'InactiveFg', 'InactiveBg' } }, - basic.divider, - { helper.separators.slant_right, { 'InactiveBg', 'black' } }, - { '🧛 ', { 'white', 'black' } }, - }, - show_in_active = true, -} - -local explorer = { - filetypes = { 'fern', 'NvimTree', 'lir' }, - active = { - { '  ', { 'white', 'black' } }, - { helper.separators.slant_right, { 'black', 'black_light' } }, - { b_components.divider, '' }, - { b_components.file_name(''), { 'white', 'black_light' } }, - }, - show_in_active = true, -} -windline.setup({ - colors_name = function(colors) - -- ADD MORE COLOR HERE ---- - return colors - end, - statuslines = { - default, - quickfix, - explorer, - }, -}) diff --git a/nvim/plugin/autocmds.vim b/nvim/plugin/autocmds.vim index 42021fd..f701dda 100644 --- a/nvim/plugin/autocmds.vim +++ b/nvim/plugin/autocmds.vim @@ -15,14 +15,18 @@ if !exists('autocommands_loaded') && has('autocmd') au TextYankPost * silent! lua vim.highlight.on_yank{timeout = 80, on_visual=true} au FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false } au BufEnter * set fo-=c fo-=r fo-=o + au CursorHold,CursorHoldI * lua vim.lsp.diagnostic.show_line_diagnostics({focusable=false}) aug END aug OnSave au BufWritePre * if index(ftToIgnore, &ft) < 0 | :%s/\s\+$//e - au BufWritePre * silent! lua vim.lsp.buf.formatting_sync() au BufWritePost init.lua PackerSync - au BufWritePost *xresources !xrdb % - au BufWritePost *sxhkdrc !pkill -USR1 sxhkd au QuitPre * if empty(&buftype) | lclose | endif aug END + + let statusline_blacklist = ['terminal', 'fugitive', 'vista', 'diagnostics', 'qf'] + aug StatusLine + au WinEnter,BufEnter * if index(statusline_blacklist, &ft) < 0 | setlocal statusline=%!v:lua.StatusLine() + au WinLeave,BufLeave * if index(statusline_blacklist, &ft) < 0 | setlocal statusline=%!v:lua.StatusLineInactive() + aug END endif diff --git a/nvim/plugin/disabled.lua b/nvim/plugin/disabled.lua index 2394b1d..563b045 100644 --- a/nvim/plugin/disabled.lua +++ b/nvim/plugin/disabled.lua @@ -1,10 +1,10 @@ local disabled_builtin_plugins = { - 'gzip', - 'zip', - 'zipPlugin', - 'tar', - 'tarPlugin', - 'getscript', + "gzip", + "zip", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", "getscriptPlugin", "vimball", "vimballPlugin", @@ -22,11 +22,11 @@ local disabled_providers = { "ruby", "node", "python", - "perl" + "perl", } for _, provider in pairs(disabled_providers) do vim.g["loaded_" .. provider .. "_provider"] = 0 end -vim.g.python3_host_prog = '/bin/python3' +vim.g.python3_host_prog = "/bin/python3" diff --git a/nvim/plugin/statusline.lua b/nvim/plugin/statusline.lua index 9f5a1b0..14fe334 100644 --- a/nvim/plugin/statusline.lua +++ b/nvim/plugin/statusline.lua @@ -1,60 +1,166 @@ -local function get_git_status() - local head = vim.b.gitsigns_head or '' - local signs = vim.b.gitsigns_status or '' - if signs == '' then - if head == '-' or head == '' then - return '' - end - return string.format(' %s', head) - end - return string.format(' %s %s', head, signs) +-- setup truncation limits +local truncation_limit = 120 + +-- is buffer horizontally truncated +Is_htruncated = function(width) + local current_width = vim.api.nvim_win_get_width(0) + return current_width < width end -local function get_lsp_info() - if vim.lsp.buf.server_ready() then - local hints = vim.lsp.diagnostic.get_count(0, 'Hint') - local warnings = vim.lsp.diagnostic.get_count(0, 'Warning') - local errors = vim.lsp.diagnostic.get_count(0, 'Error') - return string.format(' :%d  :%d  :%d ', hints, warnings, errors) +-- diagnostics symbol config +local symbol_config = { + indicator_hint = " ", + indicator_info = " ", + indicator_warning = " ", + indicator_error = " ", +} + +-- statusline colors +local statusline_colors = { + active = "%#StatusLine#", + inactive = "%#StatusLineNC#", + git = "%#diffChanged#", + err = "%#LspDiagnosticsDefaultError#", + warn = "%#LspDiagnosticsDefaultWarning#", + nfo = "%#LspDiagnosticsDefaultInformation#", + hnt = "%#LspDiagnosticsDefaultHint#", + line_col = "%#Delimiter#", + percentage = "%#Delimiter#", +} + +-- get git information of current file +local get_git_status = function() + local meta = {} + local gitsigns_summary = vim.b.gitsigns_status_dict + if not gitsigns_summary then + return "" + end + meta["branch"] = gitsigns_summary["head"] + meta["added"] = gitsigns_summary["added"] + meta["modified"] = gitsigns_summary["changed"] + meta["removed"] = gitsigns_summary["removed"] + if Is_htruncated(truncation_limit) then + return string.format(" %s", meta["branch"]) else - return '' + return string.format("  %s +%s ~%s -%s", meta["branch"], meta["added"], meta["modified"], meta["removed"]) end end -local function is_modified() - if vim.bo.modified then - return ' [+]' +-- get current file name +local get_filename = function() + if Is_htruncated(truncation_limit) then + return "%t " end - return '' + return "%<%F " end -local function get_file_info() - return ' %l:%c' +-- get current line/col +local get_line_col = function() + return " %l:%c" end -function Get_flags() - return '%h%w%m%r' +-- get current percentage through file +local get_percentage = function() + if Is_htruncated(truncation_limit) then + return "" + else + return " %p%%" + end end -function Get_file_name() - return '%<%F' +local get_flags = function() + return "%h%w%m " end -function Color_as(value, group) - return string.format('%%#%s#%s', group, value) +-- get current file diagnostics +local get_diagnostics = function() + if #vim.lsp.buf_get_clients(0) == 0 then + return "" + end + + local status_parts = {} + local errors = vim.lsp.diagnostic.get_count(0, [[Error]]) + + if errors > 0 then + table.insert(status_parts, statusline_colors.err .. symbol_config.indicator_error .. errors) + end + + if not Is_htruncated(truncation_limit) then + local warnings = vim.lsp.diagnostic.get_count(0, [[Warning]]) + local hints = vim.lsp.diagnostic.get_count(0, [[Hint]]) + local infos = vim.lsp.diagnostic.get_count(0, [[Info]]) + + if warnings > 0 then + table.insert(status_parts, statusline_colors.warn .. symbol_config.indicator_warning .. warnings) + end + + if infos > 0 then + table.insert(status_parts, statusline_colors.nfo .. symbol_config.indicator_info .. infos) + end + + if hints > 0 then + table.insert(status_parts, statusline_colors.hnt .. symbol_config.indicator_hint .. hints) + end + end + + local status_diagnostics = vim.trim(table.concat(status_parts, " ")) + if status_diagnostics ~= "" then + return status_diagnostics .. " " + end + return "" end -local status_line_template = '%s%s%%=%s%%=%s%s' +-- inactive statusline +local statusline_inactive = function() + local flags = get_flags() + local filename = get_filename() + local line_col = get_line_col() + local percentage = get_percentage() -function RenderStatusLine() - return string.format( - status_line_template, - Color_as(get_lsp_info(), 'diffChanged'), - Color_as(Get_flags(), 'StatusLine'), - Color_as(Get_file_name(), 'StatusLine'), - Color_as(get_git_status(), 'diffChanged'), - Color_as(get_file_info(), 'StatusLineNC') - ) + return table.concat({ + statusline_colors.inactive, + flags, + filename, + "%=% ", + line_col, + percentage, + }) end -vim.o.statusline = '%!v:lua.RenderStatusLine()' +-- active statusline +local statusline_normal = function() + local diagnostics = get_diagnostics() + local flags = statusline_colors.active .. get_flags() + local filename = statusline_colors.active .. get_filename() + local git = statusline_colors.git .. get_git_status() + local line_col = statusline_colors.line_col .. get_line_col() + local percentage = statusline_colors.percentage .. get_percentage() + + return table.concat({ + diagnostics, + flags, + "%=% ", + filename, + "%=% ", + git, + line_col, + percentage, + }) +end + +-- module +M = {} + +-- generate statusline +StatusLine = function() + return statusline_normal() +end +M.StatusLine = StatusLine + +-- generate inactive statusline +StatusLineInactive = function() + return statusline_inactive() +end +M.StatusLineInactive = StatusLineInactive + +return M diff --git a/xbpaketes b/xbpaketes index 7cbd3a5..a4c34ec 100644 --- a/xbpaketes +++ b/xbpaketes @@ -1,6 +1,7 @@ MangoHud-0.6.5_1 SDL-1.2.15_12 SDL_mixer-1.2.12_14 +StyLua-0.11.1_1 alacritty-0.9.0_1 alsa-plugins-1.2.5_1 alsa-plugins-ffmpeg-1.2.5_1 @@ -18,7 +19,7 @@ base-system-0.114_1 bat-0.18.3_1 blender-2.93.5_1 bspwm-0.9.10_1 -catgirl-1.9a_1 +catgirl-1.9a_2 cgo-0.6.1_1 chrony-4.1_1 cmake-3.21.1_1 @@ -30,7 +31,7 @@ dkms-2.8.4_2 droidcam-1.7.3_1 dunst-1.6.1_1 elinks-0.14.3_1 -fcitx-4.2.9.8_4 +fcitx-4.2.9.8_5 fcitx-configtool-0.4.10_2 fcitx-mozc-2.26.4472.102_2 fd-8.2.1_1 @@ -41,7 +42,7 @@ figlet-fonts-20150508_4 file-roller-3.40.0_1 firefox-94.0_1 font-misc-misc-1.1.2_7 -fzf-0.27.3_1 +fzf-0.28.0_2 git-2.33.1_1 git-libsecret-2.33.1_1 glu-9.0.2_2 @@ -51,7 +52,7 @@ gnome-ssh-askpass-8.8p1_1 gnupg2-2.2.32_1 go-1.17.2_1 golangci-lint-1.42.1_1 -gopls-0.7.2_1 +gopls-0.7.3_1 grub-2.06_2 gzdoom-4.7.1_1 highlight-4.1_2 @@ -64,8 +65,8 @@ keychain-2.8.5_2 krita-4.4.8_2 lf-r26_1 libdrm-32bit-2.4.107_1 -libfcitx-gtk-4.2.9.8_4 -libfcitx-gtk3-4.2.9.8_4 +libfcitx-gtk-4.2.9.8_5 +libfcitx-gtk3-4.2.9.8_5 libgcc-32bit-10.2.1pre1_3 libglvnd-32bit-1.3.3_1 libstdc++-32bit-10.2.1pre1_3 @@ -88,8 +89,9 @@ mosh-1.3.2_23 mpv-0.34.0_1 msmtp-1.8.18_1 mumble-1.3.4_7 +ncdu-1.16_1 ncurses-devel-6.2_4 -neomutt-20210205_2 +neomutt-20211029_1 neovim-0.5.1_2 newsboat-2.25_1 nfs-utils-2.5.4_1 @@ -117,12 +119,12 @@ rofi-emoji-2.2.0_1 rsync-3.2.3_3 runit-nftables-20200123_2 setxkbmap-1.3.2_1 -shellcheck-0.7.2_2 +shellcheck-0.8.0_1 shfmt-3.4.0_1 simple-mtpfs-0.4.0_1 snooze-0.5_1 socklog-void-20200115_2 -steam-1.0.0.72_1 +steam-1.0.0.73_1 sv-netmount-0.1_3 sxhkd-0.6.2_1 sxiv-26_1 @@ -163,4 +165,5 @@ zathura-cb-0.1.9_1 zathura-pdf-mupdf-0.3.7_3 zip-3.0_6 zsh-5.8_2 +zsh-history-substring-search-1.0.2_2 zsh-syntax-highlighting-0.7.1_3 diff --git a/zsh/.zshrc b/zsh/.zshrc index 39bb65e..e6fa822 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -27,10 +27,14 @@ setopt PROMPT_SUBST [ -n "$DISPLAY" ] && source ${ZDOTDIR}/tmux.zsh +source $XDG_DATA_HOME/lscolors.sh +source "$ZDOTDIR/other.zsh" + foreach programa ( - doc/fzf/completion.zsh - doc/fzf/key-bindings.zsh + fzf/completion.zsh + fzf/key-bindings.zsh zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh + zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh ) { source /usr/share/$programa } @@ -38,6 +42,3 @@ foreach programa ( for f in ${ZDOTDIR}/conf/*; do source "${f}" done - -source $XDG_DATA_HOME/lscolors.sh -source "$ZDOTDIR/other.zsh" diff --git a/zsh/conf/00_prompt.zsh b/zsh/conf/00_prompt.zsh deleted file mode 100644 index ca76871..0000000 --- a/zsh/conf/00_prompt.zsh +++ /dev/null @@ -1,49 +0,0 @@ -function precmd() { - if [ -z "$NEW_LINE_BEFORE_PROMPT" ]; then - NEW_LINE_BEFORE_PROMPT=1 - elif [ "$NEW_LINE_BEFORE_PROMPT" -eq 1 ]; then - echo "\n" - fi - print -Pn "\e]0;zsh %(1j,%j job%(2j|s|); ,)%2~\a" -} - -function preexec { - printf "\033]0;%s\a" "$1" -} - -autoload -Uz vcs_info -precmd_vcs_info() { vcs_info } -precmd_functions+=( precmd_vcs_info ) -setopt prompt_subst -zstyle ':vcs_info:git:*' formats '%b' -zstyle ':vcs_info:*' enable git - -function () { - if [[ $EUID == 0 ]]; then - local SUFFIX='%(?,%F{yellow},%F{red})%n%f:' - else - local SUFFIX='%(?,%F{yellow},%F{red})>%f' - fi - - PS1="%B${SUFFIX}%b " - if [[ -n $TMUX ]]; then - export RPS1="%F{green}\$vcs_info_msg_0_%f %B%(?..%{%F{red}%}(%?%)%{%f%})" - else - export RPS1="%F{green}\$vcs_info_msg_0_%f %B%(?..%{%F{red}%}(%?%)%{%f%}) %b%F{12}%2~%f" - fi -} -export SPROMPT="zsh: correct %F{red}'%R'%f to %F{green}'%r'%f [%B%Uy%u%bes, %B%Un%u%bo, %B%Ue%u%bdit, %B%Ua%u%bbort]? " - -function zle-keymap-select { - case $KEYMAP in - vicmd) echo -ne '\e[2 q';; - viins|main) echo -ne '\e[6 q';; - esac -} -zle -N zle-keymap-select - -_fix_cursor() { - echo -ne '\e[6 q' -} - -precmd_functions+=(_fix_cursor) diff --git a/zsh/conf/10_plugins.zsh b/zsh/conf/10_plugins.zsh index 8e46251..6c7c676 100644 --- a/zsh/conf/10_plugins.zsh +++ b/zsh/conf/10_plugins.zsh @@ -1,20 +1,9 @@ foreach plugin ( zsh-autopair/autopair.plugin.zsh zsh-system-clipboard/zsh-system-clipboard.plugin.zsh - zsh-history-substring-search/zsh-history-substring-search.plugin.zsh - # forgit/forgit.plugin.zsh ) { source $ZDOTDIR/conf/$plugin } -typeset -A ZSH_HIGHLIGHT_REGEXP -ZSH_HIGHLIGHT_REGEXP+=(' -{1,2}[a-zA-Z0-9_-]*' fg=008) - -# FORGIT_COPY_CMD='xclip -selection clipboard' - -# FORGIT_LOG_FZF_OPTS=' -# --bind="ctrl-e:execute(echo {} | grep -Eo [a-f0-9]+ | head -1 | xargs git show | vim -)" -# ' - HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=1 -# typeset -g ZSH_SYSTEM_CLIPBOARD_TMUX_SUPPORT='true' +typeset -g ZSH_SYSTEM_CLIPBOARD_TMUX_SUPPORT='true' diff --git a/zsh/conf/11_git-extras-completion.zsh b/zsh/conf/11_git-extras-completion.zsh deleted file mode 100644 index d6c8d1e..0000000 --- a/zsh/conf/11_git-extras-completion.zsh +++ /dev/null @@ -1,509 +0,0 @@ -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for git-extras (https://github.com/tj/git-extras). -# -# This depends on and reuses some of the internals of the _git completion -# function that ships with zsh itself. It will not work with the _git that ships -# with git. -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Alexis GRIMALDI (https://github.com/agrimaldi) -# * spacewander (https://github.com/spacewander) -# -# ------------------------------------------------------------------------------ -# Inspirations -# ----------- -# -# * git-extras (https://github.com/tj/git-extras) -# * git-flow-completion (https://github.com/bobthecow/git-flow-completion) -# -# ------------------------------------------------------------------------------ - - -# Internal functions -# These are a lot like their __git_* equivalents inside _git - -__gitex_command_successful () { - if (( ${#*:#0} > 0 )); then - _message 'not a git repository' - return 1 - fi - return 0 -} - -__gitex_commits() { - declare -A commits - git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit - do - hash=$(echo $commit | cut -d':' -f1) - commits[$hash]="$commit" - done - local ret=1 - _describe -t commits commit commits && ret=0 -} - -__gitex_remote_names() { - local expl - declare -a remote_names - remote_names=(${(f)"$(_call_program remotes git remote 2>/dev/null)"}) - __git_command_successful || return - _wanted remote-names expl remote-name compadd $* - $remote_names -} - -__gitex_tag_names() { - local expl - declare -a tag_names - tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) - __git_command_successful || return - _wanted tag-names expl tag-name compadd $* - $tag_names -} - - -__gitex_branch_names() { - local expl - declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) - __git_command_successful || return - _wanted branch-names expl branch-name compadd $* - $branch_names -} - -__gitex_specific_branch_names() { - local expl - declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/}) - __git_command_successful || return - _wanted branch-names expl branch-name compadd - $branch_names -} - -__gitex_chore_branch_names() { - __gitex_specific_branch_names 'chore' -} - -__gitex_feature_branch_names() { - __gitex_specific_branch_names 'feature' -} - -__gitex_refactor_branch_names() { - __gitex_specific_branch_names 'refactor' -} - -__gitex_bug_branch_names() { - __gitex_specific_branch_names 'bug' -} - -__gitex_submodule_names() { - local expl - declare -a submodule_names - submodule_names=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"}) # ' - __git_command_successful || return - _wanted submodule-names expl submodule-name compadd $* - $submodule_names -} - - -__gitex_author_names() { - local expl - declare -a author_names - author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"}) - __git_command_successful || return - _wanted author-names expl author-name compadd $* - $author_names -} - -# subcommands -_git-authors() { - _arguments -C \ - '(--list -l)'{--list,-l}'[show authors]' \ - '--no-email[without email]' \ -} - -_git-bug() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 - - case $state in - (command) - declare -a commands - commands=( - 'finish:merge bug into the current branch' - ) - _describe -t commands command commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - (finish) - _arguments -C \ - ':branch-name:__gitex_bug_branch_names' - ;; - -r|--remote ) - _arguments -C \ - ':remote-name:__gitex_remote_names' - ;; - esac - return 0 - esac - - _arguments \ - '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' -} - - -_git-changelog() { - _arguments \ - '(-l --list)'{-l,--list}'[list commits]' \ -} - -_git-chore() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 - - case $state in - (command) - declare -a commands - commands=( - 'finish:merge and delete the chore branch' - ) - _describe -t commands command commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - (finish) - _arguments -C \ - ':branch-name:__gitex_chore_branch_names' - ;; - -r|--remote ) - _arguments -C \ - ':remote-name:__gitex_remote_names' - ;; - esac - return 0 - esac - - _arguments \ - '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' -} - -_git-coauthor() { - _arguments \ - ':co-author[co-author to add]' \ - ':co-author-email[email address of co-author to add]' -} - -_git-contrib() { - _arguments \ - ':author:__gitex_author_names' -} - - -_git-count() { - _arguments \ - '--all[detailed commit count]' -} - -_git-create-branch() { - local curcontext=$curcontext state line - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' - - case "$state" in - (command) - _arguments \ - '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - -r|--remote ) - _arguments -C \ - ':remote-name:__gitex_remote_names' - ;; - esac - esac -} - -_git-delete-branch() { - _arguments \ - ':branch-name:__gitex_branch_names' -} - - -_git-delete-submodule() { - _arguments \ - ':submodule-name:__gitex_submodule_names' -} - - -_git-delete-tag() { - _arguments \ - ':tag-name:__gitex_tag_names' -} - - -_git-effort() { - _arguments \ - '--above[ignore file with less than x commits]' -} - - -_git-extras() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 - - case $state in - (command) - declare -a commands - commands=( - 'update:update git-extras' - ) - _describe -t commands command commands && ret=0 - ;; - esac - - _arguments \ - '(-v --version)'{-v,--version}'[show current version]' -} - - -_git-feature() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 - - case $state in - (command) - declare -a commands - commands=( - 'finish:merge feature into the current branch' - ) - _describe -t commands command commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - (finish) - _arguments -C \ - ':branch-name:__gitex_feature_branch_names' - ;; - -r|--remote ) - _arguments -C \ - ':remote-name:__gitex_remote_names' - ;; - esac - return 0 - esac - - _arguments \ - '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' -} - -_git-graft() { - _arguments \ - ':src-branch-name:__gitex_branch_names' \ - ':dest-branch-name:__gitex_branch_names' -} - -_git-guilt() { - _arguments -C \ - '(--email -e)'{--email,-e}'[display author emails instead of names]' \ - '(--ignore-whitespace -w)'{--ignore-whitespace,-w}'[ignore whitespace only changes]' \ - '(--debug -d)'{--debug,-d}'[output debug information]' \ - '-h[output usage information]' -} - -_git-ignore() { - _arguments -C \ - '(--local -l)'{--local,-l}'[show local gitignore]' \ - '(--global -g)'{--global,-g}'[show global gitignore]' \ - '(--private -p)'{--private,-p}'[show repo gitignore]' -} - - -_git-ignore() { - _arguments -C \ - '(--append -a)'{--append,-a}'[append .gitignore]' \ - '(--replace -r)'{--replace,-r}'[replace .gitignore]' \ - '(--list-in-table -l)'{--list-in-table,-l}'[print available types in table format]' \ - '(--list-alphabetically -L)'{--list-alphabetically,-L}'[print available types in alphabetical order]' \ - '(--search -s)'{--search,-s}'[search word in available types]' -} - - -_git-merge-into() { - _arguments '--ff-only[merge only fast-forward]' - _arguments \ - ':src:__gitex_branch_names' \ - ':dest:__gitex_branch_names' -} - -_git-missing() { - _arguments \ - ':first-branch-name:__gitex_branch_names' \ - ':second-branch-name:__gitex_branch_names' -} - - -_git-refactor() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 - - case $state in - (command) - declare -a commands - commands=( - 'finish:merge refactor into the current branch' - ) - _describe -t commands command commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - (finish) - _arguments -C \ - ':branch-name:__gitex_refactor_branch_names' - ;; - -r|--remote ) - _arguments -C \ - ':remote-name:__gitex_remote_names' - ;; - esac - return 0 - esac - - _arguments \ - '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' -} - - -_git-squash() { - _arguments '--squash-msg[commit with the squashed commit messages]' - _arguments \ - ':branch-name:__gitex_branch_names' -} - -_git-stamp() { - _arguments -C \ - '(--replace -r)'{--replace,-r}'[replace stamps with same id]' -} - -_git-standup() { - _arguments -C \ - '-a[Specify the author of commits. Use "all" to specify all authors.]' \ - '-d[Show history since N days ago]' \ - '-D[Specify the date format displayed in commit history]' \ - '-f[Fetch commits before showing history]' \ - '-g[Display GPG signed info]' \ - '-h[Display help message]' \ - '-L[Enable the inclusion of symbolic links]' \ - '-m[The depth of recursive directory search]' \ - '-B[Display the commits in branch groups]' -} - -_git-summary() { - _arguments '--line[summarize with lines rather than commits]' - _arguments '--dedup-by-email[remove duplicate users by the email address]' - __gitex_commits -} - - -_git-undo(){ - _arguments -C \ - '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \ - '(--hard -h)'{--hard,-h}'[wipes your commit(s)]' -} - -zstyle -g existing_user_commands ':completion:*:*:git:*' user-commands - -zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ - alias:'define, search and show aliases' \ - archive-file:'export the current head of the git repository to an archive' \ - authors:'generate authors report' \ - back:'undo and stage latest commits' \ - bug:'create bug branch' \ - bulk:'run bulk commands' \ - changelog:'generate a changelog report' \ - chore:'create chore branch' \ - clear-soft:'soft clean up a repository' \ - clear:'rigorously clean up a repository' \ - coauthor: 'add a co-author to the last commit' \ - commits-since:'show commit logs since some date' \ - contrib:'show user contributions' \ - count:'show commit count' \ - create-branch:'create branches' \ - delete-branch:'delete branches' \ - delete-merged-branches:'delete merged branches' \ - delete-submodule:'delete submodules' \ - delete-tag:'delete tags' \ - delta:'lists changed files' \ - effort:'show effort statistics on file(s)' \ - extras:'awesome git utilities' \ - feature:'create/merge feature branch' \ - force-clone:'overwrite local repositories with clone' \ - fork:'fork a repo on github' \ - fresh-branch:'create fresh branches' \ - gh-pages:'create the github pages branch' \ - graft:'merge and destroy a given branch' \ - guilt:'calculate change between two revisions' \ - ignore-io:'get sample gitignore file' \ - ignore:'add .gitignore patterns' \ - info:'returns information on current repository' \ - local-commits:'list local commits' \ - lock:'lock a file excluded from version control' \ - locked:'ls files that have been locked' \ - merge-into:'merge one branch into another' \ - merge-repo:'merge two repo histories' \ - missing:'show commits missing from another branch' \ - mr:'checks out a merge request locally' \ - obliterate:'rewrite past commits to remove some files' \ - paste:'send patches to pastebin sites' \ - pr:'checks out a pull request locally' \ - psykorebase:'rebase a branch with a merge commit' \ - pull-request:'create pull request to GitHub project' \ - reauthor:'replace the author and/or committer identities in commits and tags' \ - rebase-patch:'rebases a patch' \ - refactor:'create refactor branch' \ - release:'commit, tag and push changes to the repository' \ - rename-branch:'rename a branch' \ - rename-tag:'rename a tag' \ - rename-remote:'rename a remote' \ - repl:'git read-eval-print-loop' \ - reset-file:'reset one file' \ - root:'show path of root' \ - scp:'copy files to ssh compatible `git-remote`' \ - sed:'replace patterns in git-controlled files' \ - setup:'set up a git repository' \ - show-merged-branches:'show merged branches' \ - show-tree:'show branch tree of commit history' \ - show-unmerged-branches:'show unmerged branches' \ - squash:'import changes from a branch' \ - stamp:'stamp the last commit message' \ - standup:'recall the commit history' \ - summary:'show repository summary' \ - sync:'sync local branch with remote branch' \ - touch:'touch and add file to the index' \ - undo:'remove latest commits' \ - unlock:'unlock a file excluded from version control'