vimrc YSSS

This commit is contained in:
Benjamin Kyd
2023-05-21 22:33:54 +01:00
parent f5431f2b47
commit ec7a130ded
10 changed files with 107 additions and 203 deletions

View File

@@ -1,5 +1,10 @@
require('basics')
require('globals')
require('keymappings')
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')
vim.cmd('source ~/.vimrc')
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "NONE" })
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "NONE" })
vim.api.nvim_set_hl(0, "CmpItemMenu", { bg = "NONE" })
require('plugins')
require('post-plugin-basics')

View File

@@ -1,108 +0,0 @@
-- ================= Holy leader key ================= --
vim.g.mapleader = ','
vim.keymap.set({'n', 'v', 'o', 's'}, '<space>', '<leader>', {remap = true})
-- ================= File management ================= --
-- swapfile has global & local config, eventhough help says otherwise
vim.o.swapfile = false -- can open already open files
vim.bo.swapfile = false
vim.o.backup = false
vim.o.writebackup = false
vim.o.autoread = true -- auto file change detection
-- clipboard
vim.opt.clipboard = "unnamedplus"
-- autocmds are currently not supported by nvim (0.5 nighlty)
vim.api.nvim_command([[
" Triger `autoread` when files changes on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
]])
-- ================= Scrolling ================= --
vim.o.scrolloff = 8 -- start scrolling when 8 lines away from margins
-- ================= Indentation ================= --
-- pay attention to 'vim.bo' (buffer local options) and 'vim.o' (global options)
-- see :help options.txt
-- for some reason these values need to be set in both o and bo objects
-- eventhough these options are supposed to be local to buffer
vim.o.tabstop = 4 -- maximum width of tab character (measured in spaces)
vim.bo.tabstop = 4
vim.o.shiftwidth = 4 -- size of indent (measured in spaces), should equal tabstop
vim.bo.shiftwidth = 4
vim.o.softtabstop = 4 -- should be the same as the other two above
vim.bo.softtabstop = 4
vim.o.expandtab = true -- expand tabs to spaces
vim.bo.expandtab = true -- expand tabs to spaces
vim.o.smartindent = true -- smart indenting on new line for C-like programs
vim.bo.smartindent = true
vim.o.autoindent = true -- copy the indentation from previous line
vim.bo.autoindent = true
vim.o.smarttab = true -- tab infront of a line inserts blanks based on shiftwidth
-- ================= Number column ================= --
vim.wo.number = true
vim.cmd [[
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
]] -- h/t https://jeffkreeftmeijer.com/vim-number/
-- ================= Search ================= --
vim.o.ignorecase = true -- Ignorecase when searching
vim.o.incsearch = true -- start searching on each keystroke
vim.o.smartcase = true -- ignore case when lowercase, match case when capital case is used
vim.o.hlsearch = true -- highlight the search results
-- ================= Performance ================= --
vim.o.lazyredraw = false -- useful for when executing macros.
vim.o.ttimeoutlen = 30 -- ms to wait for a key code seq to complete
-- ================= NETRW ================= --
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 3
vim.g.netrw_browse_split = 4
vim.g.netrw_altv = 1
vim.g.netrw_winsize = 25
-- ================= Misc ================= --
vim.wo.wrap = true -- wrap long text into multiple lines
vim.o.history = 10000 -- numbers of entries in history for ':' commands and search patterns (10000 = max)
vim.o.updatetime = 300 -- used for CursorHold event (for document highlighting detection)
vim.o.mouse = 'nv' -- allow mose in normal & visual mode
-- we want splits to be to the bottom and to the right
vim.o.splitright = true
vim.o.splitbelow = true
-- better autocomplete behaviour
-- menuone - show popup menu also when there is only one match available
-- preview - show extra information about currently selected completion
-- noinsert - do not insert any text for match until the user selects it from the menu
vim.o.completeopt='menuone,preview,noinsert'
-- allows hidden buffers
-- this means that a modified buffer doesn't need to be saved when changing
-- tabs/windows.
vim.o.hidden=true
-- Copy paste between vim and everything else
vim.o.clipboard = "unnamedplus"

View File

@@ -1,2 +0,0 @@
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')

View File

@@ -1,31 +0,0 @@
-- defaults
local opts = { noremap = true, silent = true }
-- paste in insert mode
vim.api.nvim_set_keymap('i', '<C-v>', '<Esc>"+pa', opts)
-- paste and keep the paste register
vim.api.nvim_set_keymap('', '<leader>p', '"_dP', opts)
-- peek registers
vim.api.nvim_set_keymap('n', '<leader>r', ':Telescope registers<CR>', opts)
-- vscode style quick peek at the tree
vim.api.nvim_set_keymap('n', '<C-b>', ":Lexplore<CR><C-w><S-l>:vertical resize 30<CR>", { noremap = true })
-- make ctrl-shift arrows line movement
vim.api.nvim_set_keymap('n', '<C-K>', 'ddkP', opts)
vim.api.nvim_set_keymap('v', '<C-K>', ':m \'<-2<CR>gv=gv', opts)
vim.api.nvim_set_keymap('n', '<C-J>', 'ddp', opts)
vim.api.nvim_set_keymap('v', '<C-J>', ':m \'>+1<CR>gv=gv', opts)
-- Mapping U to Redo.
vim.api.nvim_set_keymap('', 'U', '<C-r>', opts)
vim.api.nvim_set_keymap('', '<C-r>', '<NOP>', opts)
-- indent via Tab
vim.api.nvim_set_keymap('v', '<Tab>', '>>_', opts)
vim.api.nvim_set_keymap('v', '<S-Tab>', '<<_', opts)
vim.api.nvim_set_keymap('i', '<Tab>', '\t', opts)
vim.api.nvim_set_keymap('i', '<S-Tab>', '\b', opts)

View File

@@ -171,3 +171,4 @@ vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true })
vim.diagnostic.config({
virtual_text = true
})

View File

@@ -45,6 +45,13 @@ local packer = require('packer').startup(function(use)
require('harpoon').setup({
tabline = true,
})
vim.keymap.set("n", "<leader>hg", require("harpoon.mark").toggle_file, { desc = "Add file to harpoon list" })
vim.keymap.set("n", "<leader>hh", require("harpoon.ui").toggle_quick_menu, { desc = "Toggle harpoon menu" })
for pos = 1, 9 do
vim.keymap.set("n", "<leader>h" .. pos, function()
require("harpoon.ui").nav_file(pos)
end, { desc = "Move to harpoon mark #" .. pos })
end
end
}
@@ -89,6 +96,9 @@ local packer = require('packer').startup(function(use)
'folke/zen-mode.nvim',
config = function()
require('zen-mode').setup({})
vim.keymap.set("n", "<leader>z", function()
require("zen-mode").toggle()
end, { desc = "Toggle Zen Mode" })
end
}

View File

@@ -1,52 +1,5 @@
-- ################# Basic settings dependent on plugins ################ --
-- ==================== KEYS ======================= --
-- Harpoon
--vim.cmd('highlight! HarpoonNumberActive guibg=NONE guifg=#f5bde6')
--vim.cmd('highlight! HarpoonNumberInactive guibg=NONE guifg=#6e738d')
--vim.cmd('highlight! TabLineFill guibg=#24273a guifg=#cad3f5')
vim.keymap.set("n", "<leader>hh", require("harpoon.ui").toggle_quick_menu, { desc = "Toggle Harpoon Menu" })
vim.keymap.set("n", "<leader>hg", require("harpoon.mark").toggle_file, { desc = "Add file to harpoon list" })
for pos = 1, 9 do
vim.keymap.set("n", "<leader>h" .. pos, function()
require("harpoon.ui").nav_file(pos)
end, { desc = "Move to harpoon mark #" .. pos })
end
-- Zen mode
vim.keymap.set("n", "<leader>z", function()
require("zen-mode").toggle()
end, { desc = "Toggle Zen Mode" })
-- ================= Visualization ================= --
vim.o.termguicolors = true
vsm.o.termguicolors = true
vim.o.background = 'dark'
--require('kanagawa').setup({
--undercurl = true, -- enable undercurls
--commentStyle = { italic = true },
--functionStyle = {},
--keywordStyle = { italic = true},
--statementStyle = { bold = true },
--typeStyle = {},
--variablebuiltinStyle = { italic = true},
--transparent = false, -- do not set background color
--dimInactive = false, -- dim inactive window `:h hl-NormalNC`
--globalStatus = true, -- adjust window separators highlight for laststatus=3
--terminalColors = true, -- define vim.g.terminal_color_{0,17}
--colors = {
--bg = '#22222d',
--},
--overrides = {},
--theme = "default" -- Load "default" theme or the experimental "light" theme
--})
-- setup must be called before loading
vim.cmd("colorscheme kanagawa")
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "NONE" })
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "NONE" })
vim.api.nvim_set_hl(0, "CmpItemMenu", { bg = "NONE" })

View File

@@ -25,7 +25,7 @@ label-urgent = %name%
label-focused-padding = 1
label-unfocused-padding = 1
label-visible-padding = 1
label-urgent-padding = 0
label-urgent-padding = 1
label-separator-padding = 0
label-focused-background = ${colors.pink}

85
common/.vimrc Normal file
View File

@@ -0,0 +1,85 @@
colorscheme kanagawa
set confirm
set noswapfile
set termguicolors
set autoread
set clipboard=unnamedplus
" Triger `autoread` when files changes on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
set scrolloff=4
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smartindent
set autoindent
set smarttab
set wrap
set ignorecase
set smartcase
set incsearch
set hlsearch
set number
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
set nolazyredraw
set timeoutlen=600
let g:netrw_banner=0
let g:netrw_liststyle=3
let g:netrw_browse_split=4
let g:netrw_altv=1
let g:netrw_winsize=25
set history=1000
set updatetime=69
set mouse=nvi
set cursorline
set splitbelow
set splitright
set completeopt=menu,menuone,preview,noinsert,noselect
set guicursor=a:block,i:ver20,v-r:hor20
" The holy leader key
let g:mapleader=","
map <space> <leader>
" Drag lines
nn <C-K> ddkP
vn <C-K> :m '<-2<cr>gv=gv
nn <C-J> ddp
vn <C-J> :m '>+1<cr>gv=gv
" Take a peek at netrw
nn <C-b> :Lexplore<cr><C-w><S-l>:vertical resize 30<cr>
" Paste in insert mode
ino <C-v> <Esc>"+pa
" Clear search
nn <Esc> :nohlsearch<cr>
" Better redo
nn U <C-r>
nn <C-r> <nop>
" Peep the registers
nn <lader>r :Telescope registers<cr>
" Paste and keep the " register
nn <leader>p "_dP

View File

@@ -7,16 +7,8 @@ plugins=(git fancy-ctrl-z fzf)
source $ZSH/oh-my-zsh.sh
# more based keybinginds for regular ass typing
#source /usr/share/zsh/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh
ZVM_VI_EDITOR=vim
# aliases
alias vim=nvim
alias vi=nvim
alias v=nvim
alias oldvim=vim
export VISUAL=nvim;
export EDITOR=nvim;
@@ -33,7 +25,6 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
source $HOME/.zshrc.local
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm