diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index e690851..570ca9f 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -2,6 +2,9 @@ set fish_cursor_default block # Set the normal and visual mode cursors to a bloc set fish_cursor_insert line # Set the insert mode cursor to a line set fish_cursor_replace_one underscore # Set the replace mode cursor to an underscore +# Force fish to skip some checks (I think) +set fish_vi_force_cursor + function fish_user_key_bindings # Use the vim keybinds fish_vi_key_bindings diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 4838477..4e3bf89 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -1,36 +1,4 @@ -local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') -local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() -local g = vim.g -- a table to access global variables -local opt = vim.opt -- to set options - --- Basic options -opt.joinspaces = false -- No double spaces with join -opt.list = true -- Show some invisible characters - -opt.number = true -- Show line numbers -opt.relativenumber = true -- Relative line numbers - -opt.scrolloff = 4 -- Lines of context -opt.shiftround = true -- Round indent -opt.shiftwidth = 2 -- Size of an indent -opt.termguicolors = true -- True color support - -opt.ignorecase = true -- Ignore case -opt.smartcase = true -- Do not ignore case with capitals - -opt.smartindent = true -- Insert indents automatically - -opt.splitbelow = true -- Put new windows below current -opt.splitright = true -- Put new windows right of current - -opt.wrap = false -- Disable line wrap -opt.wildmode = {'list', 'longest'} -- Command-line completion mode - -opt.completeopt = {"menu", "menuone", "noselect"} - --- Set theme -require('github-theme').setup({theme_style = "light", dark_float = true}) - -- Import my other files +require("my.options").setup() require('my.keymaps').setup() require('my.plugins').setup() diff --git a/dotfiles/neovim/lua/my/helpers.lua b/dotfiles/neovim/lua/my/helpers.lua index e127a43..1db593d 100644 --- a/dotfiles/neovim/lua/my/helpers.lua +++ b/dotfiles/neovim/lua/my/helpers.lua @@ -4,4 +4,13 @@ function M.global(name, value) vim.g[name] = value end +function M.mergeTables(t1, t2) + local t3 = {} + + for k, v in pairs(t1) do t3[k] = v end + for k, v in pairs(t2) do t3[k] = v end + + return t3 +end + return M diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index 32a377e..8b4c187 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -1,20 +1,21 @@ +local helpers = require("my.helpers") + local M = {} function M.map(mode, lhs, rhs, opts) - local options = {noremap = true} - if opts then options = vim.tbl_extend('force', options, opts) end + local options = helpers.mergeTables(opts, {noremap = true}) vim.api.nvim_set_keymap(mode, lhs, rhs, options) end function M.mapSilent(mode, lhs, rhs, opts) - local options = {silent = true} - if opts then options = vim.tbl_extend('force', options, opts) end - M.map(mode, lhs, rhs, opts) + local options = helpers.mergeTables(opts, {silent = true}) + M.map(mode, lhs, rhs, options) end function M.setup() M.map("i", "jj", "") -- Remap Esc to jj M.map("n", "", ":w") -- Double space to sace + M.map("n", "vv", "v") -- Create vertical split end return M diff --git a/dotfiles/neovim/lua/my/options.lua b/dotfiles/neovim/lua/my/options.lua new file mode 100644 index 0000000..5c6d04e --- /dev/null +++ b/dotfiles/neovim/lua/my/options.lua @@ -0,0 +1,39 @@ +local helpers = require("my.helpers") + +local M = {} + +function M.setup() + local opt = vim.opt -- to set options + + -- Basic options + opt.joinspaces = false -- No double spaces with join + opt.list = true -- Show some invisible characters + + opt.number = true -- Show line numbers + opt.relativenumber = true -- Relative line numbers + + opt.scrolloff = 4 -- Lines of context + opt.shiftround = true -- Round indent + opt.shiftwidth = 2 -- Size of an indent + opt.termguicolors = true -- True color support + + opt.ignorecase = true -- Ignore case + opt.smartcase = true -- Do not ignore case with capitals + + opt.smartindent = true -- Insert indents automatically + + opt.splitbelow = true -- Put new windows below current + opt.splitright = true -- Put new windows right of current + + opt.wrap = false -- Disable line wrap + opt.wildmode = {'list', 'longest'} -- Command-line completion mode + opt.completeopt = {"menu", "menuone", "noselect"} + + -- Set leader + helpers.global("mapleader", "") + + -- Set theme + require('github-theme').setup({theme_style = "light", dark_float = true}) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/arpeggio.lua b/dotfiles/neovim/lua/my/plugins/arpeggio.lua new file mode 100644 index 0000000..8e98120 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/arpeggio.lua @@ -0,0 +1,21 @@ +local helpers = require("my.helpers") +local arpeggio = vim.fn["arpeggio#map"] + +local M = {} + +function M.chord(mode, lhs, rhs, opts) + local options = helpers.mergeTables(opts, {noremap = true}) + + local settings = "" + + if options.silent then settings = settings .. "s" end + + arpeggio(mode, settings, options.noremap, lhs, rhs) +end + +function M.chordSilent(mode, lhs, rhs, opts) + local options = helpers.mergeTables(opts, {silent = true}) + M.chord(mode, lhs, rhs, options) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index 68655d4..74776e6 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -17,6 +17,7 @@ function M.setup() require("my.plugins.nvim-tree").setup() require("my.plugins.vimtex").setup() require("my.plugins.telescope").setup() + require("my.plugins.vimux").setup() end return M diff --git a/dotfiles/neovim/lua/my/plugins/vimux.lua b/dotfiles/neovim/lua/my/plugins/vimux.lua new file mode 100644 index 0000000..794ea3a --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/vimux.lua @@ -0,0 +1,9 @@ +local arpeggio = require("my.plugins.arpeggio") + +local M = {} + +function M.setup() + arpeggio.chordSilent("n", "vp", ":VimuxPromptCommand") +end + +return M diff --git a/dotfiles/tmux/tmux.conf b/dotfiles/tmux/tmux.conf index 993e059..5fe8340 100644 --- a/dotfiles/tmux/tmux.conf +++ b/dotfiles/tmux/tmux.conf @@ -3,37 +3,37 @@ set -g prefix C-a unbind C-b bind C-a send-prefix -# More colors -set-option -g default-terminal "tmux-256color" -set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q' +# don't rename windows automatically +set-option -g allow-rename off -# force a reload of the config file (I don't think this works on nixos) -unbind r -bind r source-file ~/.tmux.conf +# Visual stuff +set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q' # Supposedly helps with cursor shapes under vim (spoiler: it does not) -# quick pane cycling -unbind ^A -bind ^A select-pane -t :.+ +# Split panes with \ and - +bind \\ split-window -h +bind - split-window -v +unbind '"' +unbind % + +# Zooming +unbind C-z +bind -n C-z resize-pane -Z # Vim-like keybinds for switching between panes -bind -n m-h select-pane -L -bind -n m-l select-pane -R -bind -n m-k select-pane -U -bind -n m-j select-pane -D +bind -n C-h select-pane -L +bind -n C-l select-pane -R +bind -n C-k select-pane -U +bind -n C-j select-pane -D # Vim-mode set-window-option -g mode-keys vi -# Vim like keybinds for copying -bind -t vi-copy v begin-selection # begin selection -bind -t vi-copy V rectangle-toggle # square selection (?) - -bind -t vi-copy y copy-pipe 'xclip -in -set clipboard' # copy - -unbind p -bind p run "tmux set-buffer \"$(xclip -o -set clipboard)\"; tmux paste-buffer" # paste - # Vim like mode for leaving insert mode unbind [ # unbind the default way to copy text -bind Escape copy-mode # allow exiting insert mode with Escape -bind jj copy-mode # allow exiting insert mode with jj (?) +bind -T prefix j copy-mode # allow exiting insert mode with C-a j + +# Vim like keybinds for copying and pasting +bind -T copy-mode-vi p paste-buffer +bind -T copy-mode-vi V send-keys -X rectangle-toggle # Check if this works +bind -T copy-mode-vi v send-keys -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-selection diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index da66474..b457bba 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -57,6 +57,8 @@ in telescope-file-browser-nvim # file creation/deletion using telescope lspkind-nvim # show icons in lsp completion menus # symbols-outline-nvim # tree view for symbols in document + vimux # interact with tmux from within vim + vim-tmux-navigator # easly switch between tmux and vim panes # Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp cmp-nvim-lsp diff --git a/modules/applications/tmux.nix b/modules/applications/tmux.nix index 8ef5034..b70107c 100644 --- a/modules/applications/tmux.nix +++ b/modules/applications/tmux.nix @@ -16,11 +16,11 @@ ]; extraConfig = '' - # load the rest of the config - source-file ${../../dotfiles/tmux/tmux.conf} - # Use github light theme source-file ${pkgs.githubNvimTheme}/terminal/tmux/github_light.conf + + # load the rest of the config + source-file ${../../dotfiles/tmux/tmux.conf} ''; }; };