From 616da83956eb6e66c6f36ab05d86f6a5a8ca6a24 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 00:45:59 -0700 Subject: [PATCH 01/20] Minor changes to a comment --- .zshrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 24206ec..57e1eef 100644 --- a/.zshrc +++ b/.zshrc @@ -465,14 +465,15 @@ bindkey '^[Oc' forward-word # bindkey '^[Od' backward-word # bindkey '^[[1;5D' backward-word # bindkey '^[[1;5C' forward-word # +# Delete words with ctrl+bksp/del bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace bindkey '^[[3;5~' kill-word # delete next word with ctrl+delete bindkey '^[[Z' undo # Shift+tab undo last action # bind UP and DOWN arrow keys to history substring search zmodload zsh/terminfo -bindkey "$terminfo[kcuu1]" history-substring-search-up -bindkey "$terminfo[kcud1]" history-substring-search-down +# bindkey "$terminfo[kcuu1]" history-substring-search-up +# bindkey "$terminfo[kcud1]" history-substring-search-down bindkey '^[[A' history-substring-search-up bindkey '^[[B' history-substring-search-down bindkey -M vicmd 'k' history-substring-search-up From 37008f253bd3d6c727f018d2b6ed3ed4e33df5c9 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 00:52:52 -0700 Subject: [PATCH 02/20] fix for termux on android --- .zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 11278cf..c3e7fb2 100644 --- a/.zshrc +++ b/.zshrc @@ -493,7 +493,7 @@ export LESS_TERMCAP_us=$'\E[01;36m' export LESS=-R autoload -U compinit colors zcalc -compinit -d +compinit -d 2>&1 > /dev/null colors # <<< ### Various manjaro ZSH functions >>> From d8eb5763c1a0c4458385df6214c7d9814b711540 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 00:54:03 -0700 Subject: [PATCH 03/20] uncommented some important lines --- .zshrc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.zshrc b/.zshrc index c3e7fb2..cfdbbe4 100644 --- a/.zshrc +++ b/.zshrc @@ -376,12 +376,12 @@ zinit load "zsh-users/zsh-completions" # Themes - # terminal colors - # if [[ -f ~/.config/shell/colors.sh ]];then - # source ~/.config/shell/colors.sh - # else - # zinit snippet 'https://github.com/chriskempson/base16-shell/blob/master/scripts/base16-onedark.sh' # onedark shell colors - # fi + terminal colors + if [[ -f ~/.config/shell/colors.sh ]];then + source ~/.config/shell/colors.sh + else + zinit snippet 'https://github.com/chriskempson/base16-shell/blob/master/scripts/base16-onedark.sh' # onedark shell colors + fi zinit load "romkatv/powerlevel10k" zinit ice atclone"dircolors -b ./src/dir_colors > colors.zsh" \ atpull'%atclone' pick"colors.zsh" nocompile'!' \ From 7c9ce3740840a9d8fd28e9df9446a96f18f8780c Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 00:55:59 -0700 Subject: [PATCH 04/20] Fixed comment --- .zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index cfdbbe4..ac37624 100644 --- a/.zshrc +++ b/.zshrc @@ -375,8 +375,8 @@ zinit load "zsh-users/zsh-history-substring-search" zinit load "zsh-users/zsh-completions" - # Themes - terminal colors + ## Themes + # terminal colors if [[ -f ~/.config/shell/colors.sh ]];then source ~/.config/shell/colors.sh else From 6f2a76ffdf75090ee599e845016172917ef8b8f9 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 02:07:28 -0700 Subject: [PATCH 05/20] Modified todo alias. Make the todo file into a symlink file that points to the actual todo file, in whatever format you want it to be now. --- .zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index ac37624..f8ea0c1 100644 --- a/.zshrc +++ b/.zshrc @@ -87,7 +87,7 @@ alias \ nvc="(cd ~/.config/nvim && nvim)" \ zshrc="$EDITOR ~/.zshrc" \ - todo="$EDITOR ~/todo.md" \ + todo="$EDITOR ~/todo" \ fstab="sudo $EDITOR /etc/fstab" \ # Git cLONE From c322f4899f87306e35fd28aa372bd1236baf386f Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 02:58:25 -0700 Subject: [PATCH 06/20] improved `todo` alias by changing it into a function --- .zshrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index f8ea0c1..91c1c14 100644 --- a/.zshrc +++ b/.zshrc @@ -1,7 +1,7 @@ #!/bin/zsh # Blake's ZSH config file -# vim:fdm=marker:fmr=>>>,<<<:expandtab:sw=3 +# vim:fdm=marker:fmr=>>>,<<<:et:ft=zsh:sw=3 ### Basic shell configuration >>> ### Environment variables >>> @@ -87,7 +87,6 @@ alias \ nvc="(cd ~/.config/nvim && nvim)" \ zshrc="$EDITOR ~/.zshrc" \ - todo="$EDITOR ~/todo" \ fstab="sudo $EDITOR /etc/fstab" \ # Git cLONE @@ -157,6 +156,13 @@ done } + # an improved way to manage the todo list + todo() { + cd "$(dirname "$(realpath ~/todo)")" + test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull + "$EDITOR" ~/todo + } + # Simple extraction script. Taken from manjaro's .bashrc ex() { if [ -f $1 ] ; then From 076362fd808810bcf1380eef364aaf31d2555b9b Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 10:06:18 -0700 Subject: [PATCH 07/20] QOL improvements --- .zshrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 91c1c14..20bbaa6 100644 --- a/.zshrc +++ b/.zshrc @@ -85,7 +85,7 @@ # Edit config files alias \ - nvc="(cd ~/.config/nvim && nvim)" \ + nvc="(cd ~/.config/nvim/lua && nvim)" \ zshrc="$EDITOR ~/.zshrc" \ fstab="sudo $EDITOR /etc/fstab" \ @@ -317,6 +317,7 @@ echo 'Error: Could not `cd` into the repo' return 1 fi + ls } calc() { From 6658296ef92fd511ee85fe7a5d5e98aaf804f8a3 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 21:38:22 -0700 Subject: [PATCH 08/20] improvements to todo() --- .zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 20bbaa6..502b299 100644 --- a/.zshrc +++ b/.zshrc @@ -158,9 +158,12 @@ # an improved way to manage the todo list todo() { + ( cd "$(dirname "$(realpath ~/todo)")" - test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull + # only pull the repo if there is some argument + [ -z "$1" ] || test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull "$EDITOR" ~/todo + ) } # Simple extraction script. Taken from manjaro's .bashrc From ab46fcd6da667c90192f5aa2c5fc10ef3f959440 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 21:39:21 -0700 Subject: [PATCH 09/20] added markdown preview plugin --- .config/nvim/lua/plugins.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 0f80237..3caaea6 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -141,6 +141,10 @@ return require('packer').startup(function() require('other').autosession() end } + use { + 'ellisonleao/glow.nvim', + ft = { 'md', 'markdown', } + } -- Conveniences use { -- Undo tree From 61ed74a2c6e7c21231de959a6695cc8c909ae051 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 21:42:31 -0700 Subject: [PATCH 10/20] Initial DAP support --- .config/nvim/lua/lsp.lua | 68 ++++++++++++++++++++++++++++-------- .config/nvim/lua/plugins.lua | 21 ++++++++--- 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index ec8d378..a3322cf 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -1,14 +1,15 @@ local M = {} -M.signature = function() ---- lsp_signature >>> +-- lsp_signature >>> +M.signature = function() require "lsp_signature".setup() cfg = { Gse_lspsaga = true } -end --- <<< +end -- <<< -M.lspinstall = function() ---- lspinstall >>> +-- lspinstall >>> +M.lspinstall = function() -- local function setup_servers() require'lspinstall'.setup() local servers = require'lspinstall'.installed_servers() @@ -24,10 +25,10 @@ M.lspinstall = function() ---- lspinstall >>> setup_servers() -- reload installed servers vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server end -end --- <<< +end -- <<< -M.treesitter = function() ---- treesitter >>> +-- treesitter >>> +M.treesitter = function() require('nvim-treesitter.configs').setup { highlight = { enable = true, -- false will disable the whole extension @@ -95,10 +96,10 @@ M.treesitter = function() ---- treesitter >>> -- enable = true -- } -- } -end --- <<< +end -- <<< -M.cmp = function() ---- cmp >>> +-- cmp >>> +M.cmp = function() -- nvim-cmp supports additional completion capabilities local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) @@ -175,10 +176,10 @@ M.cmp = function() ---- cmp >>> end, }, } -end --- <<< +end -- <<< -M.lspconfig = function() ---- lspconfig >>> +-- lspconfig >>> +M.lspconfig = function() local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys @@ -225,8 +226,45 @@ M.lspconfig = function() ---- lspconfig >>> } } end -end --- <<< +end -- <<< + +-- DAP: Debug Adapter Protocol >>> +M.dap = function() + -- default keybinds + vim.cmd [[ + nnoremap lua require'dap'.continue() + nnoremap lua require'dap'.step_over() + nnoremap lua require'dap'.step_into() + nnoremap lua require'dap'.step_out() + nnoremap b lua require'dap'.toggle_breakpoint() + nnoremap B lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) + nnoremap lp lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) + nnoremap dl lua require'dap'.run_last() + nnoremap dr lua require'dap'.repl.open() + ]] + local dap = require('dap') + dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = true, + }, + } +end -- <<< + +-- DAP installer >>> +M.dapinstall = function() + local dap_install = require("dap-install") + + dap_install.setup({ + installation_path = vim.fn.stdpath("data") .. "/dapinstall/", + }) +end -- <<< return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 0f80237..3b4da53 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -10,7 +10,7 @@ end return require('packer').startup(function() -- Packer - use { -- plugins + use { -- packer 'wbthomason/packer.nvim' } @@ -45,6 +45,18 @@ return require('packer').startup(function() -- end, 0) -- end, } + use { -- DAP: Debug Adapter Protocol >>> + "mfussenegger/nvim-dap", + config = function() + require("lsp").dap() + end + } + use { + "Pocco81/DAPInstall.nvim", + config = function() + require("lsp").dapinstall() + end + } use { -- Default LSP configs "neovim/nvim-lspconfig", after = "nvim-lspinstall", @@ -107,9 +119,9 @@ return require('packer').startup(function() requires = { 'nvim-lua/plenary.nvim' }, - -- config = function() - -- require('other').gitsigns() - -- end + config = function() + require('other').gitsigns() + end, } use { -- file manager 'kyazdani42/nvim-tree.lua', @@ -168,7 +180,6 @@ return require('packer').startup(function() use { -- tpope: Repeatability for various tpope plugins 'tpope/vim-repeat', } - end) -- vim:fdm=marker:fmr={,}:expandtab:tabstop=3:sw=3 From b41d1693b40163c360c546efbc8e06acc206769f Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 21:42:49 -0700 Subject: [PATCH 11/20] Gitsigns config --- .config/nvim/lua/other.lua | 81 ++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 7 deletions(-) diff --git a/.config/nvim/lua/other.lua b/.config/nvim/lua/other.lua index 25013bb..142f6c3 100644 --- a/.config/nvim/lua/other.lua +++ b/.config/nvim/lua/other.lua @@ -38,8 +38,7 @@ M.nvimtree = function () { key = "q", cb = tree_cb("close") }, { key = "g?", cb = tree_cb("toggle_help") }, } -end --- <<< +end -- <<< -- toggleterm >>> M.toggleterm = function() @@ -80,10 +79,78 @@ M.toggleterm = function() } } } -end --- <<< +end -- <<< -M.autosession = function() -- Automatic session loading and saving >>> +-- gitsigns >>> +M.gitsigns = function() + require('gitsigns').setup { + 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'}, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + keymaps = { + -- Default keymap options + noremap = 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 hs'] = 'lua require"gitsigns".stage_hunk()', + ['v hs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n hu'] = 'lua require"gitsigns".undo_stage_hunk()', + ['n hr'] = 'lua require"gitsigns".reset_hunk()', + ['v hr'] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', + ['n hR'] = 'lua require"gitsigns".reset_buffer()', + ['n hp'] = 'lua require"gitsigns".preview_hunk()', + ['n hb'] = 'lua require"gitsigns".blame_line(true)', + ['n hS'] = 'lua require"gitsigns".stage_buffer()', + ['n hU'] = 'lua require"gitsigns".reset_buffer_index()', + + -- Text objects + ['o ih'] = ':lua require"gitsigns.actions".select_hunk()', + ['x ih'] = ':lua require"gitsigns.actions".select_hunk()' + }, + watch_index = { + interval = 1000, + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + }, + current_line_blame_formatter_opts = { + relative_time = false + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + yadm = { + enable = false + }, + } +end -- <<< + +-- Autosession >>> +M.autosession = function() local opts = { log_level = 'info', auto_session_enable_last_session = true, @@ -94,8 +161,8 @@ M.autosession = function() -- Automatic session loading and saving >>> auto_session_suppress_dirs = nil } require('auto-session').setup(opts) -end --- <<< + vim.cmd 'command! SessionSave SaveSession' +end -- <<< return M From e3fa159136440d182bee310084aa1c214e2e1b97 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 22:02:47 -0700 Subject: [PATCH 12/20] improved todo() --- .zshrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.zshrc b/.zshrc index 502b299..a4f1173 100644 --- a/.zshrc +++ b/.zshrc @@ -158,11 +158,13 @@ # an improved way to manage the todo list todo() { - ( - cd "$(dirname "$(realpath ~/todo)")" - # only pull the repo if there is some argument - [ -z "$1" ] || test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull - "$EDITOR" ~/todo + ( # subshell to protect against directory changes + if [ -z "$@" ];then + $EDITOR ~/todo + else + cd "$(dirname "$(realpath ~/todo)")" + git $@ + fi ) } From d8f30f27453e2d2e2cd9a30677c4c946a63b11a0 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 23:13:22 -0700 Subject: [PATCH 13/20] nvim: added DAP support with nvim-dap, but I just decided I like vimspector more --- .config/nvim/lua/lsp.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index a3322cf..ec223d7 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -232,17 +232,18 @@ end -- <<< M.dap = function() -- default keybinds vim.cmd [[ - nnoremap lua require'dap'.continue() - nnoremap lua require'dap'.step_over() - nnoremap lua require'dap'.step_into() - nnoremap lua require'dap'.step_out() - nnoremap b lua require'dap'.toggle_breakpoint() - nnoremap B lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) - nnoremap lp lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) + nnoremap b lua require'dap'.continue() + nnoremap bo lua require'dap'.step_over() + nnoremap bi lua require'dap'.step_into() + nnoremap bO lua require'dap'.step_out() + nnoremap bb lua require'dap'.toggle_breakpoint() + nnoremap bB lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) + nnoremap blp lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) nnoremap dl lua require'dap'.run_last() nnoremap dr lua require'dap'.repl.open() ]] local dap = require('dap') + -- c++ dap congiguration >>> dap.configurations.cpp = { { name = "Launch file", @@ -255,6 +256,11 @@ M.dap = function() stopOnEntry = true, }, } + dap.adapters.cppdbg = { + type = 'executable', + command = '/home/blake/.local/share/nvim/dapinstall/ccppr_vsc/extension/debugAdapters/bin/OpenDebugAD7', + } + -- <<< end -- <<< -- DAP installer >>> From 29ddd45f953971a2b376d8ca3875bd4c3d11362e Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 16 Sep 2021 00:06:55 -0700 Subject: [PATCH 14/20] Added usage to todo() --- .zshrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.zshrc b/.zshrc index a4f1173..751a5bd 100644 --- a/.zshrc +++ b/.zshrc @@ -157,6 +157,10 @@ } # an improved way to manage the todo list + # Usage: + # todo -- edit ~/todo + # todo [git command string] -- manage todo for easy syncing, assuming ~/todo is + # a symlink that points to a file in a git repo todo() { ( # subshell to protect against directory changes if [ -z "$@" ];then From 063db819b49367211edd27f2f084001516ebadb9 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 16 Sep 2021 00:40:55 -0700 Subject: [PATCH 15/20] zsh: todo() now changes the working dir --- .zshrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.zshrc b/.zshrc index 751a5bd..430fc25 100644 --- a/.zshrc +++ b/.zshrc @@ -164,6 +164,7 @@ todo() { ( # subshell to protect against directory changes if [ -z "$@" ];then + cd "$(dirname "$(realpath ~/todo)")" $EDITOR ~/todo else cd "$(dirname "$(realpath ~/todo)")" From 67c70c5bb8eb3cf5248c582dfd177343a15871bf Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 16 Sep 2021 02:16:34 -0700 Subject: [PATCH 16/20] zsh: todo() now has automatic push powers --- .zshrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 430fc25..1a3f4f1 100644 --- a/.zshrc +++ b/.zshrc @@ -159,15 +159,20 @@ # an improved way to manage the todo list # Usage: # todo -- edit ~/todo + # todo auto -- commit ~/todo and push with message 'todo' # todo [git command string] -- manage todo for easy syncing, assuming ~/todo is # a symlink that points to a file in a git repo todo() { ( # subshell to protect against directory changes + todo_dir="$(dirname "$(realpath ~/todo)")" if [ -z "$@" ];then cd "$(dirname "$(realpath ~/todo)")" $EDITOR ~/todo + elif [ "$@" = 'auto' ];then + cd "$todo_dir" + git commit "$(realpath ~/todo)" -m 'todo' && todo push else - cd "$(dirname "$(realpath ~/todo)")" + cd "$todo_dir" git $@ fi ) From 10cdfef6086c4146e6ae7027d3ae4a184cb777ae Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 16 Sep 2021 02:17:07 -0700 Subject: [PATCH 17/20] Big changes, don't remember all of them One thing is more DAP configuration --- .config/nvim/init.lua | 7 +++-- .config/nvim/lua/lsp.lua | 51 +++++++++++++++++------------------ .config/nvim/lua/other.lua | 20 +++++++++----- .config/nvim/lua/plugins.lua | 4 +-- .config/nvim/lua/settings.lua | 17 +++++++----- 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 6040620..2b9eda8 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -21,12 +21,11 @@ require('plugins') -- [ ] telescope -- [ ] zen-mode.nvim (goyo) -- [ ] status line --- [ ] chadtree keymap --- [ ] lspsaga +-- [X] lspsaga -- [ ] lightspeed.nvim or hop.nvim -- [ ] lightbulb --- [ ] glow.nvim (markdown preview) --- [ ] auto-session +-- [X] glow.nvim (markdown preview) +-- [X] auto-session -- [ ] shade.nvim -- [ ] presence.nvim (discord presence) -- [ ] trouble.nvim diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index ec223d7..376ceea 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -195,24 +195,23 @@ M.lspconfig = function() local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) - + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) end -- Use a loop to conveniently call 'setup' on multiple servers and @@ -232,14 +231,14 @@ end -- <<< M.dap = function() -- default keybinds vim.cmd [[ - nnoremap b lua require'dap'.continue() - nnoremap bo lua require'dap'.step_over() - nnoremap bi lua require'dap'.step_into() - nnoremap bO lua require'dap'.step_out() - nnoremap bb lua require'dap'.toggle_breakpoint() - nnoremap bB lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) - nnoremap blp lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) - nnoremap dl lua require'dap'.run_last() + nnoremap d lua require'dap'.continue() + nnoremap dj lua require'dap'.step_over() + nnoremap dl lua require'dap'.step_into() + nnoremap dk lua require'dap'.step_out() + nnoremap dbb lua require'dap'.toggle_breakpoint() + nnoremap dbc lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) + nnoremap dbl lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) + nnoremap dp lua require'dap'.run_last() nnoremap dr lua require'dap'.repl.open() ]] local dap = require('dap') diff --git a/.config/nvim/lua/other.lua b/.config/nvim/lua/other.lua index 142f6c3..34e7939 100644 --- a/.config/nvim/lua/other.lua +++ b/.config/nvim/lua/other.lua @@ -103,19 +103,22 @@ M.gitsigns = function() ['n [c'] = { expr = true, "&diff ? '[c' : 'lua require\"gitsigns.actions\".prev_hunk()'"}, ['n hs'] = 'lua require"gitsigns".stage_hunk()', - ['v hs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', ['n hu'] = 'lua require"gitsigns".undo_stage_hunk()', ['n hr'] = 'lua require"gitsigns".reset_hunk()', + + ['v hs'] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', ['v hr'] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', - ['n hR'] = 'lua require"gitsigns".reset_buffer()', + ['n hp'] = 'lua require"gitsigns".preview_hunk()', ['n hb'] = 'lua require"gitsigns".blame_line(true)', + ['n hS'] = 'lua require"gitsigns".stage_buffer()', + ['n hR'] = 'lua require"gitsigns".reset_buffer()', ['n hU'] = 'lua require"gitsigns".reset_buffer_index()', -- Text objects - ['o ih'] = ':lua require"gitsigns.actions".select_hunk()', - ['x ih'] = ':lua require"gitsigns.actions".select_hunk()' + ['o ih'] = 'lua require"gitsigns.actions".select_hunk()', + ['x ih'] = 'lua require"gitsigns.actions".select_hunk()' }, watch_index = { interval = 1000, @@ -158,10 +161,15 @@ M.autosession = function() auto_session_enabled = true, auto_save_enabled = false, auto_restore_enabled = true, - auto_session_suppress_dirs = nil + auto_session_suppress_dirs = nil, } require('auto-session').setup(opts) - vim.cmd 'command! SessionSave SaveSession' + -- save some more things. notably options, resize, winpos, and terminal + vim.o.sessionoptions="blank,buffers,curdir,folds,help,options,tabpages,winsize,resize,winpos,terminal" + -- So I don't forget which one it is + vim.cmd 'command! SessionSave SaveSession' + vim.cmd 'command! SessionDelete DeleteSession' + vim.cmd 'command! SessionRestore RestoreSession' end -- <<< return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 8e65a67..970edd1 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -45,13 +45,13 @@ return require('packer').startup(function() -- end, 0) -- end, } - use { -- DAP: Debug Adapter Protocol >>> + use { -- DAP: Debug Adapter Protocol "mfussenegger/nvim-dap", config = function() require("lsp").dap() end } - use { + use { -- DAP adapter installer "Pocco81/DAPInstall.nvim", config = function() require("lsp").dapinstall() diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 51743fd..ae9c57f 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -58,21 +58,24 @@ vim.cmd [[ """ Key bindings let mapleader = " " - " *sigh*... + + " *sigh*... command! Q q command! W w command! Wq wq command! WQ wq - " nnoremap ; : - " vnoremap ; : - " Press Alt h to toggle highlighting on/off, and show current value. + + " Press Alt h to toggle highlighting on/off, and show current value. noremap set hlsearch! hlsearch? noremap set spell! spell? - " Escape to enter normal mode in the terminal + + " Escape to enter normal mode in the terminal tnoremap - " Replace with alt S + + " Replace with alt S nnoremap :%s//g - " Move lines around in visual mode with J and K + + " Move lines around in visual mode with J and K vnoremap J :m '>+1gv=gv vnoremap K :m '<-2gv=gv From f20b8a6421b4e94fe96e480ee20bf0b14ef66e54 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 16 Sep 2021 02:24:30 -0700 Subject: [PATCH 18/20] Moved the vim note to the bottom --- .zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 1a3f4f1..ce247c4 100644 --- a/.zshrc +++ b/.zshrc @@ -1,8 +1,6 @@ #!/bin/zsh # Blake's ZSH config file -# vim:fdm=marker:fmr=>>>,<<<:et:ft=zsh:sw=3 - ### Basic shell configuration >>> ### Environment variables >>> { @@ -628,3 +626,5 @@ add-zsh-hook preexec mzc_termsupport_preexec # Optionally source the user's customized .zshrc [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local" || return 0 +# vim:fdm=marker:fmr=>>>,<<<:et:ft=zsh:sw=3 + From 2aabf6bb5d873d41805cf98c0790d55388453859 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Sun, 19 Sep 2021 16:35:29 -0700 Subject: [PATCH 19/20] zsh: added more usage info to todo() --- .zshrc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.zshrc b/.zshrc index ce247c4..7053fc6 100644 --- a/.zshrc +++ b/.zshrc @@ -154,12 +154,16 @@ done } - # an improved way to manage the todo list + # a simple way to manage your todo list # Usage: - # todo -- edit ~/todo - # todo auto -- commit ~/todo and push with message 'todo' - # todo [git command string] -- manage todo for easy syncing, assuming ~/todo is + # todo -- edit ~/todo + # todo auto -- commit and push ~/todo with message 'todo' + # todo [any git command] -- manage todo for easy syncing, assuming ~/todo is # a symlink that points to a file in a git repo + # + # Suggested use: make a git repo for holding your todo list, then make + # a symlink called 'todo' that points to your todo list in your home directory + # todo() { ( # subshell to protect against directory changes todo_dir="$(dirname "$(realpath ~/todo)")" @@ -168,7 +172,8 @@ $EDITOR ~/todo elif [ "$@" = 'auto' ];then cd "$todo_dir" - git commit "$(realpath ~/todo)" -m 'todo' && todo push + git commit "$(realpath ~/todo)" -m 'todo' + git push else cd "$todo_dir" git $@ @@ -626,5 +631,6 @@ add-zsh-hook preexec mzc_termsupport_preexec # Optionally source the user's customized .zshrc [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshrc.local" || return 0 -# vim:fdm=marker:fmr=>>>,<<<:et:ft=zsh:sw=3 +# filetype is sh for language server +# vim:fdm=marker:fmr=>>>,<<<:et:ft=sh:sw=3 From ec7b60a377436a1f9db9f76e1dd82c0867975db8 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Sun, 19 Sep 2021 16:45:25 -0700 Subject: [PATCH 20/20] added dotfiles init script (so you can make your own repo!) --- .local/bin/dotfiles-init.sh | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 .local/bin/dotfiles-init.sh diff --git a/.local/bin/dotfiles-init.sh b/.local/bin/dotfiles-init.sh new file mode 100755 index 0000000..a9dddcd --- /dev/null +++ b/.local/bin/dotfiles-init.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# this will setup a bare git repo for managing dotfiles. You should only run this script once per set of dotfiles. +# credit for this idea and basic script outline goes to: https://www.atlassian.com/git/tutorials/dotfiles + +set -e + +# name the path to the dotfiles repo +DOTFILES_REPO_DIR="$HOME/git/dotfiles" + +# Some colors to spice things up + Cyan="$( tput setaf 6 )" +Green="$( tput setaf 2 )" + NC="$( tput sgr0 )" # No Color + +# check for the git command and exit if it doesn't exist +if ! command -v git > /dev/null;then + echo 'git is not installed or could not be found in $PATH, please install git to proceed' + exit 1 +fi + +# an "alias" for the git command for use by the script +dot() { + git --git-dir="$DOTFILES_REPO_DIR" --work-tree="$HOME" "$@" +} + + +mkdir -p "$DOTFILES_REPO_DIR" +if git init --bare "$DOTFILES_REPO_DIR" > /dev/null 2>&1; then + echo "A bare git repository has been initialized at $DOTFILES_REPO_DIR" + echo +else + echo 'git repository initialization failed' + exit +fi +dot config --local status.showUntrackedFiles no +echo "Please add this alias to your shell's init script:" +# looks like this: alias dot="git --git-dir="/path/to/repo" --work-tree=\"$HOME\"" +echo " ${Cyan}alias dot=${Green}\"git --git-dir=\"$DOTFILES_REPO_DIR\" --work-tree=\\\"\$HOME\\\"\"${NC}" +echo "Then, you can use the command '${Cyan}dot ${Green}add ${NC}' to add a given file to the repo" +