diff --git a/.gitignore b/.gitignore index ee824c8..a3f474e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ *.swp alacritty/.config/alacritty/alacritty.yml + +nvim/.config/nvim/plugin/packer_compiled.lua +nvim/.config/nvim/undo + +vim/.config/vim/undo + zsh/.config/zsh/.zcompdump zsh/.config/zsh/.zsh_history zsh/.config/zsh/.zsh_sessions - -vim/.config/vim/undo -nvim/.config/nvim/undo diff --git a/bin/bin/toggle-color-mode b/bin/bin/toggle-color-mode index 45d2ce2..3893aa6 100755 --- a/bin/bin/toggle-color-mode +++ b/bin/bin/toggle-color-mode @@ -25,6 +25,6 @@ for pane_info in $(tmux list-panes -a -F '#{pane_id}-#{pane_current_command}'); IFS=- read pane cmd <<< "$pane_info" if [[ $cmd == "vim" || $cmd == "nvim" ]]; then - tmux send-keys -t $pane ":call ChangeBackground()" ENTER + tmux send-keys -t $pane ":lua ChangeBackground()" ENTER fi done diff --git a/install.sh b/install.sh index 6244531..127f03c 100755 --- a/install.sh +++ b/install.sh @@ -16,7 +16,7 @@ install_homebrew() { install_shared_applications() { brew install direnv fzf git stow the_silver_searcher tmux \ vim zsh rbenv ruby-build tfenv nodenv node-build tig libpq gnupg llvm \ - awscli cmake jq watch gh + awscli cmake jq watch gh nvim install_alacritty_terminfo install_rust @@ -72,13 +72,9 @@ install_rust() { } install_vim() { - if ! test -f ~/.vim/autoload/plug.vim > /dev/null; then - curl \ - --create-dirs \ - --fail \ - --location \ - --output ~/.vim/autoload/plug.vim \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + if ! test -d ~/.local/share/nvim/site > /dev/null; then + git clone --depth 1 https://github.com/wbthomason/packer.nvim \ + ~/.local/share/nvim/site/pack/packer/start/packer.nvim fi } diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..aa6db80 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,249 @@ +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +require("packer").startup(function(use) + local use = use + + use "wbthomason/packer.nvim" + -- TODO: autoupdate (but after plugins separate file + -- augroup packer_user_config + -- autocmd! + -- autocmd BufWritePost plugins.lua source | PackerCompile + -- augroup end + + use "nvim-lua/plenary.nvim" + use "nvim-telescope/telescope.nvim" + + use "nvim-treesitter/nvim-treesitter" + use "nvim-treesitter/nvim-treesitter-context" + + use "famiu/bufdelete.nvim" + use "gpanders/editorconfig.nvim" + use "johnfrankmorgan/whitespace.nvim" + use "kylechui/nvim-surround" + use "lewis6991/gitsigns.nvim" + use "nyngwang/NeoZoom.lua" -- TODO: Floating window background color + use "ruifm/gitlinker.nvim" + + use "gruvbox-community/gruvbox" +end) + +--- SETTING CONFIGURATION +vim.opt.autowrite = true +-- vim.opt.backspace = 2 -- default in neovim? +vim.opt.cpoptions:append("$") +-- vim.opt.endofline -- default in neovim? +-- vim.opt.laststatus = 2 -- default in neovim? +-- vim.opt.backup = false -- default in neovim? +vim.opt.swapfile = false +vim.opt.wrap = false +vim.opt.scrolloff = 3 +vim.opt.showmatch = true +-- vim.opt.showmode = true -- default in neovim? +-- vim.opt.showmode = true -- default in neovim? +vim.opt.timeoutlen = 500 +vim.opt.virtualedit = "all" +-- vim.opt.hlsearch = true -- default in neovim? +vim.opt.ignorecase = true +-- vim.opt.incsearch = true -- default in neovim? +vim.opt.smartcase = true +-- vim.opt.wrapscan = true -- default in neovim? + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.textwidth = 80 +vim.opt.colorcolumn = {80, 120} + +-- Tabs are 2 spaces +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true +vim.opt.shiftround = true -- make >> go to next tab + +-- undo +vim.opt.undolevels = 5000 +vim.opt.undofile = true +vim.opt.undodir = os.getenv("HOME") .. "/.config/nvim/undo" + +-- REMAP CONFIGURATION +--- Stay in visual mode while tabbing +vim.keymap.set("v", ">", ">gv") +vim.keymap.set("v", "<", "") +vim.keymap.set("v", "S", 'y:%s/"//g') + +--- COMMAND CONFIGURATION +--- Avoid typos +vim.api.nvim_create_user_command("W", "w", {}) +vim.api.nvim_create_user_command("Wq", "wq", {}) + +-- CUSTOM CONFIGURATION +--- Targetting! +local reticle = vim.api.nvim_create_augroup("Reticle", { + clear = true +}) + +vim.api.nvim_create_autocmd({"VimEnter", "WinEnter", "BufWinEnter"}, { + group = reticle, + callback = function() + vim.opt_local.cursorline = true + vim.opt_local.cursorcolumn = true + end +}) +vim.api.nvim_create_autocmd({"WinLeave"}, { + group = reticle, + callback = function() + vim.opt_local.cursorline = false + vim.opt_local.cursorcolumn = false + end +}) + +--- background matching terminal +function ChangeBackground() + local file = io.open(os.getenv("HOME") .. "/.config/atomaka/color.yml", "rb") + local background = file:read() + file:close() + vim.opt.background = background +end +ChangeBackground() + +-- LEADER CONFIGURATION +vim.g.mapleader = "," + +vim.keymap.set("n", "sz", ":luafile ~/.config/nvim/init.lua") + +vim.keymap.set({ "n", "v" }, "cp", '"+y') +vim.keymap.set({ "n", "v" }, "pa", '"+P') + +vim.keymap.set("n", "cs", ":let @/ = ''") +vim.keymap.set("n", "fj", ":%!jq .") +vim.keymap.set("n", "gg", ":exe '!gh gist create -w %:p'") + +--- tabs +vim.keymap.set("n", "2", function() + print("Setting tabstop to 2") + vim.opt.tabstop = 2 + vim.opt.shiftwidth = 2 + vim.opt.expandtab = true +end) +vim.keymap.set("n", "4", function() + print("Setting tabstop to 4") + vim.opt.tabstop = 4 + vim.opt.shiftwidth = 4 + vim.opt.expandtab = true +end) +vim.keymap.set("n", "a", function() + print("Setting tabstop to tab") + vim.opt.tabstop = 8 + vim.opt.shiftwidth = 8 + vim.opt.expandtab = false +end) +vim.keymap.set("n", "st", ':let @/ = "\t"') + +-- COLOR CONFIGURATION +vim.cmd("colorscheme gruvbox") +vim.api.nvim_create_autocmd({"ColorScheme", "BufWinEnter"}, { + callback = function() + vim.cmd("hi Normal ctermbg=NONE guibg=NONE") + end, +}) + +-- PLUGIN CONFIGURATION +--- bufdelete.nvim +vim.keymap.set("n", "bd", function() + require("bufdelete").bufdelete(0, true) +end) + +--- gitlinker.nvim +require"gitlinker".setup() +vim.keymap.set("n", "gh", function() + require"gitlinker".get_buf_range_url( + "n", + { action_callback = require"gitlinker.actions".open_in_browser } + ) +end, { silent = true }) +vim.keymap.set("v", "gh", function() + require"gitlinker".get_buf_range_url( + "v", + { action_callback = require"gitlinker.actions".open_in_browser } + ) +end) + +--- gitsigns.nvim +require("gitsigns").setup() +vim.keymap.set("n", "gb", require("gitsigns").toggle_current_line_blame) + +--- NeoZoom.lua +require("neo-zoom").setup({ + left_ratio = 0, + top_ratio = 0, + width_ratio = 1, + height_ratio = 1, + border = "none", +}) +vim.keymap.set("n", "z", require("neo-zoom").neo_zoom) + +--- nvim-surround +require("nvim-surround").setup() + +--- nvim-treesitter +require"nvim-treesitter.configs".setup { + ensure_installed = "all", + sync_install = false, + ignore_install = { "phpdoc" }, -- TODO: https://github.com/claytonrcarter/tree-sitter-phpdoc/issues/15 + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} + +-- nvim-treesitter-context +require("treesitter-context").setup({ + patterns = { + rust = { + -- default rust + "impl_item", + "struct", + "enum", + + -- substrate xD + "macro_invocation", + }, + }, +}) + +--- packer.nvim +vim.keymap.set("n", "pi", function() + vim.cmd("PackerCompile") + vim.cmd("PackerInstall") +end) +vim.keymap.set("n", "pu", ":PackerSync") +vim.keymap.set("n", "pc", ":PackerClean") + +--- telescope.nvim +vim.keymap.set("n", "", function() + require("telescope.builtin").git_files() +end) + +--- whitespace.nvim +require("whitespace-nvim").setup({ + hightlight = "red" +}) +vim.keymap.set("n", "fw", function() + require("whitespace-nvim").trim() +end, { silent = true }) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100644 index 0716b3f..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,3 +0,0 @@ -set runtimepath+=~/.vim,~/.vim/after -set packpath+=~/.vim -source ~/.vimrc diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 0762e1f..b5fafef 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -8,6 +8,7 @@ bind-key b send-prefix set -g automatic-rename off set -g renumber-windows on +set -g history-limit 100000 set-option -sg escape-time 10 set-option -g base-index 1 set-window-option -g monitor-activity off diff --git a/vim/.vimrc b/vim/.vimrc index bec7c55..c27c1f5 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -21,9 +21,6 @@ Plug 'vim-ruby/vim-ruby' " colors Plug 'morhetz/gruvbox' -" testing -Plug 'wellle/context.vim' " consider nvim-treesitter-context - call plug#end() " STATUS LINE @@ -154,18 +151,7 @@ augroup END set cursorline set cursorcolumn -" crosshair -set cursorline -set cursorcolumn - -" crosshair -set cursorline -set cursorcolumn - " PLUGIN CONFIGURATION -" context.vim -let g:context_highlight_border = '' - " editorconfig-vim let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']