Compare commits

..

41 Commits

Author SHA1 Message Date
psox 1bd880676c tmux: add ctrl-shift-movement 2022-09-29 16:39:29 +01:00
psox 7c50a5acd6 update formatting 2022-09-16 12:02:52 +01:00
psox d31c1c8a8e recursive update 2022-09-16 11:54:18 +01:00
psox 32144ad5d5 fix grep error 2022-09-16 11:41:33 +01:00
psox 8a5f61b47f finish merge 2022-09-13 20:05:51 +01:00
psox 9fbd124ee0 Merge branch 'develop' into psox/arch 2022-09-13 20:04:45 +01:00
pSox b1ea115f31 ci: merge new lua config 2022-08-02 10:21:42 +01:00
pSox e2df4d1e48 Merge remote-tracking branch 'origin/develop' into psox/arch 2022-08-02 10:14:09 +01:00
psox 663e4ece08 set nolist on leader-N 2022-06-06 11:19:34 +01:00
psox eadc268fe6 set go ts 2022-06-06 10:34:21 +01:00
psox cdc44a9df9 update add zoxide support 2022-05-17 10:22:41 +01:00
psox aabf03d69b merge some local tmux config changes to git 2022-05-06 13:37:23 +01:00
psox 53f8ad5c2c Fix changes to zshrc 2022-04-05 14:28:18 +01:00
psox 5f0eda8bae Update sub-modules 2022-04-05 14:20:31 +01:00
psox c434926442 add suuport for bat as man reader 2021-12-22 14:17:52 +00:00
psox 091de18feb fix paru entry 2021-11-29 15:34:10 +00:00
psox db33642b75 added support keys.conf to tmux 2021-11-06 13:25:44 +00:00
psox 2b523a19f2 fix copy bug in zshrc 2021-11-04 15:59:05 +00:00
psox e561295485 fix fragments folder 2021-11-04 15:24:24 +00:00
psox 85ec09df86 consolodate with develop 2021-11-04 15:12:19 +00:00
psox b6adf06830 consolodate with develop 2021-11-04 15:11:58 +00:00
psox 29a95ec965 fix src for omz updates 2021-11-01 10:42:23 +00:00
psox 6f8d3e06ef Latest submodule updates and support for paru 2021-11-01 10:30:15 +00:00
psox b641630b18 Latest submodule updates 2021-08-08 21:02:04 +01:00
psox 8a2f11d866 Merge remote-tracking branch 'origin/develop' into psox/arch 2021-08-08 20:57:01 +01:00
psox 0aa8fdde46 Added support for starship and did some cleanup 2021-07-22 20:27:21 +01:00
psox 8539579b65 fix problem with xhost 2021-07-08 16:37:58 +01:00
psox a7b7ef5401 make grep quiet 2021-07-07 10:43:47 +01:00
psox d4ef219b73 get latest from develop 2021-07-07 10:41:36 +01:00
psox 67a0b2e147 Latest submodule updates 2021-04-25 12:30:44 +01:00
psox 6fab471628 Merge remote-tracking branch 'origin/develop' into psox/arch 2021-04-25 12:25:47 +01:00
psox c2018cb742 Latest submodule updates 2021-04-02 11:32:44 +00:00
root 1a8e70fe0f added ~/.local/bin to path 2020-12-18 13:22:42 +00:00
psox 08a8946fdc Latest Updates 2020-12-13 14:20:43 +00:00
psox aa8fa4ed6e Merge branch 'develop' into psox/arch 2020-12-10 10:28:51 +00:00
psox 570ca8d8b4 added 10k 2020-11-12 15:37:51 +00:00
psox cca71f6735 latest changes 2020-11-02 16:38:12 +00:00
psox 743555992c latest changes 2020-11-02 16:35:23 +00:00
psox 8643f5585b latest changes 2020-10-30 23:43:47 +00:00
psox bd2878fe91 latest changes 2020-10-29 11:46:05 +00:00
psox e91859c988 Updates and more 2020-09-24 13:19:59 +00:00
57 changed files with 1183 additions and 2085 deletions

8
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "oh-my-zsh"]
path = oh-my-zsh
url = https://git.st8l.com/dolysis/ohmyzsh.git
url = https://github.com/robbyrussell/oh-my-zsh.git
[submodule "zsh-custom/plugins/zsh-autosuggestions"]
path = zsh-custom/plugins/zsh-autosuggestions
url = https://github.com/zsh-users/zsh-autosuggestions
@ -25,9 +25,3 @@
[submodule "tmux/plugins/tpm"]
path = tmux/plugins/tpm
url = https://github.com/tmux-plugins/tpm
[submodule "zsh-custom/plugins/zsh-vi-mode"]
path = zsh-custom/plugins/zsh-vi-mode
url = https://github.com/jeffreytse/zsh-vi-mode
[submodule "nvim/lazy.nvim"]
path = nvim/lazy.nvim
url = https://github.com/folke/lazy.nvim.git

View File

@ -10,14 +10,13 @@ This is optimized by default for dark terminals, and contains configurations for
use with
- zsh >= v5.8
- neovim >= v0.9
- neovim >= v0.6
- tmux >= 3.2
All of these have standard setting but can be customized by using optional
include files. Please read the following configs
- `vimrc`
- `init.lua`
- `zshrc`
- `tmux/tmux.conf`
@ -49,7 +48,8 @@ them and then run the following commands.
(
git pull --recurse-submodules=yes
git submodule foreach git fetch --all --prune
git submodule update --remote --rebase
git submodule foreach git checkout master
git submodule foreach git pull
git pull --recurse-submodules=yes
)
@ -63,7 +63,7 @@ src
```bash
git clone --recurse-submodules --recursive https://git.st8l.com/dolysis/psoxizsh.git ~/.psoxizsh
git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git ~/.psoxizsh
# This should work on Linux. It is not tested on MacOS or Windows
~/.psoxizsh/fresh-system
@ -75,7 +75,7 @@ git clone --recurse-submodules --recursive https://git.st8l.com/dolysis/psoxizsh
```bash
# Make sure you are root
git clone --recurse-submodules --recursive https://git.st8l.com/dolysis/psoxizsh.git /etc/psoxizsh
git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git /etc/psoxizsh
# This should work on Linux. It is not tested on MacOS or Windows
# for each user that wants to use this as the user run this command
@ -85,7 +85,7 @@ git clone --recurse-submodules --recursive https://git.st8l.com/dolysis/psoxizsh
## Configure NeoVim
Make sure you have neovim (tested on v0.9.x, v0.10.x) installed and after starting zsh
Make sure you have neovim (tested on v0.6.1) installed and after starting zsh
check that the following variable are set by typing
You will need to install `neovim`, `nodejs` and `npm` to get the full use of vim
@ -93,14 +93,10 @@ You will need to install `neovim`, `nodejs` and `npm` to get the full use of vim
Just start neovim (`nvim`) and wait for it to finish. After that quit and it
should be ready to use.
You can also use: `nvim --headless '+Lazy! sync' +TSUpdate +qa` to sync all plugins
without opening neovim.
See the default entrypoint ([init.lua](./init.lua)) for more details on how to
configure your local setup further.
```bash
nvim ~/.config/nvim/init.lua
echo $VIMINIT
echo $MYVIMRC
echo $VIMHOME
```
Enjoy

View File

@ -1,23 +0,0 @@
set-option -g prefix C-a
bind-key C-a last-window
bind-key a send-prefix
#set -g mode-mouse off
#set -g mouse-resize-pane off
#set -g mouse-select-pane off
#set -g mouse-select-window off
set -g base-index 1
set -s escape-time 0
setw -g aggressive-resize on
setw -g monitor-activity on
set -g visual-activity on
set -g status-left ' #[fg=blue,bold]#h #S:#I.#P (#D) #[default]'
set -g status-right '#T #[fg=yellow,bold]#(uptime | cut -d, -f4 | cut -d " " -f 4-7)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default] '
set -g status-fg '#EEEEEE'
set -g status-bg '#333333'
set -g set-titles on
bind-key e set-window-option synchronize-panes on
bind-key E set-window-option synchronize-panes off
bind m set -g mode-mouse on \; set -g mouse-resize-pane on \; set -g mouse-select-pane on \; set -g mouse-select-window on \; display 'Mouse: ON'
bind M set -g mode-mouse off \; set -g mouse-resize-pane off \; set -g mouse-select-pane off \; set -g mouse-select-window off \; display 'Mouse: OFF'
bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom
bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom

View File

@ -1,52 +0,0 @@
set guifont=Fira\ Code\ 11
set encoding=utf-8
set nocompatible
colorscheme murphy
syntax on
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules according to the
" detected filetype. Per default Debian Vim only load filetype specific
" plugins.
if has("autocmd")
filetype indent on
endif
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set smartcase " Do smart case matching
set incsearch " Incremental search
set ww=b,s,<,>,[,]
set sta
set visualbell
set mousemodel=popup_setpos
highlight SpellErrors ctermfg=Red guifg=Red cterm=underline gui=underline term=reverse
let spell_language_list = "americanxlg,american,americanmed+,english"
let spell_insert_mode = 1
let spell_executable = "ispell"
let spell_auto_type = ""
"let spell_auto_type = "tex,mail,text,html,sgml,otl,cvs,none"
" other
set shiftwidth=2
set tabstop=8
set softtabstop=2
set expandtab
filetype plugin indent on
autocmd FileType yaml setl indentkeys-=<:>
autocmd FileType yaml setlocal ts=8 sts=2 sw=2 expandtab
set modeline
set modelines=7
" vim: syntax=vim

View File

@ -1,74 +0,0 @@
{
// cspell: enableCompoundWords
"coc.preferences.formatOnSaveFiletypes": [
"json",
"jsonc",
"rust",
"markdown",
"xml",
"html",
"css",
"lua",
"go"
],
"markdownlint.config": {
"line-length": {
"line_length": 120
}
},
"coc.preferences.enableMarkdown": false,
"prettier.proseWrap": "always",
"diagnostic.errorSign": "", //
"diagnostic.warningSign": "", //
"diagnostic.hintSign": "", //
"diagnostic.infoSign": "", //
"diagnostic.checkCurrentLine": false,
"diagnostic.level": "hint",
"diagnostic.autoRefresh": true,
"diagnostic.refreshOnInsertMode": false,
"diagnostic.locationlistUpdate": true,
"diagnostic.virtualText": true,
"diagnostic.signPriority": 20,
"diagnostic.enableHighlightLineNumber": false,
"suggest.disableMenu": false,
"suggest.snippetIndicator": "",
"suggest.languageSourcePriority": 100,
"suggest.enablePreview": true,
"suggest.removeDuplicateItems": true,
"suggest.detailField": "preview",
"suggest.labelMaxLength": 100,
"suggest.noselect": false,
"suggest.selection": "recentlyUsedByPrefix",
"suggest.acceptSuggestionOnCommitCharacter": true,
"suggest.completionItemKindLabels": {
"default": "",
"text": "", //
"method": "", //
"function": "", // ƒ
"constructor": "", //
"field": "", //
"variable": "", //
"class": "", //
"interface": "", //
"module": "", //
"property": "", //
"unit": "", //
"value": "",
"enum": "", //
"keyword": "", //
"snippet": "", //
"color": "",
"file": "", //
"reference": "", //
"folder": "", //
"enumMember": "", //
"constant": "", //
"struct": "פּ", //
"event": "", //
"operator": "Ψ", //
"typeParameter": "" //
},
"Lua.telemetry.enable": false
// cspell: ignore struct
// vim: filetype=jsonc
}

View File

@ -1,94 +1,3 @@
--[[
This is entrypoint Psoxizsh uses to start Neovim.
The majority of configuration can be done via the following files:
~/.config/nvim
lua
   config
      autocmds.lua | Any additional autocmds (late loaded)
      keymaps.lua | Any additional key binds (late loaded)
      lazy.lua |
      options.lua | Any vim.opt or vim.g configuration (early loaded)
   plugins | Any additional plugins, changes to existing
   spec1.lua | plugins, plugin specific key binds, etc.
   specN.lua |
init.lua | <--- You are here
autocmds.lua:
Any custom autocommands to create.
You can use `psoxizsh.autocmd` as a helper for creating these.
Example:
local au = psoxizsh.autocmd
au.MyCustomGroup {
{ 'VimEnter', 'yaml', ':silent echo opened a YAML file!' }
}
keymaps.lua:
Any additional key binds to create.
You can use the builtin `vim.keymap.set` to create these. See :h vim.keymap
for more details.
Example:
local map = vim.keymap.set
map('n', '<leader>:', function() print('using a lua function') end)
map({ 'i', 'v' }, '<leader>:', '<cmd>silent echo using a vim cmdstring<CR>')
options.lua:
Any extra options you wish to set.
Unlike other files, options.lua is loaded *EARLY*, before most initialization
happens, letting you set things like mapleader, background color, etc before
other things that use this information are loaded.
However, this also means that (excluding parts of psoxizsh itself) you cannot
access any plugin related configuration.
Example:
local opt, g = vim.opt, vim.g
g.mapleader = ','
plugins/*.lua
Any direct submodules in the plugin/ directory will have their plugin specs
merged and loaded during initialization.
A full description of a plugin is beyond the purview of this document, but
briefly, each spec object describes where to source it, how to configure it,
when to load it, and any additional plugins it depends on.
These specs are then merged according to the following rules:
- cmd : the list of commands will be extended with your custom commands
- event : the list of events will be extended with your custom events
- ft : the list of filetypes will be extended with your custom filetypes
- keys : the list of keymaps will be extended with your custom keymaps
- opts : your custom opts will be merged with the default opts
- dependencies: the list of dependencies will be extended with your custom dependencies
- any other property will override the defaults
See https://lazy.folke.io/spec for the full spec description, or look at
some of the examples in $PSOXIZSH/nvim/lua/psoxizsh/plugins for more.
---
Unless you wish to change the options passed directly to our package manager,
you do not need to change this file. If you do, copy this file to your local
~/.config/nvim/init.lua and make the modifications needed:
cp -v $PSOXIZSH/init.lua ~/.config/nvim/init.lua
Next, add the following line (replacing 'overrides' with your config overrides)
just above the call to .start():
require('psoxizsh.entrypoint.config').with(overrides)
--]]
vim.opt.rtp:append( os.getenv('PSOXIZSH') .. '/nvim' )
require('psoxizsh.entrypoint').start()
require 'psoxizsh'

@ -1 +0,0 @@
Subproject commit 48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d

View File

@ -4,13 +4,15 @@ local Groups = {}
local Group = { mt = {} }
local AutoCmd = { mt = {} }
local __builtin_support = vim.fn.has('nvim-0.7') == 1
-- Use the recent builtin APIs provided by neovim itself
local function builtin(group, autos)
local gid = vim.api.nvim_create_augroup(group, { clear = true })
vim.api.nvim_create_augroup(group, {})
for _, auto in ipairs(autos) do
local opts = auto.opts or {}
opts.group = gid
opts.group = group
opts.pattern = auto.pattern
if type(auto.command) == "string" then
@ -23,7 +25,31 @@ local function builtin(group, autos)
end
end
local autocmd = builtin
-- Use an old library to make the autos
-- Note that relies on the local package manager to ensure this plugin is available
local function polyfill(group, autos)
local poly = require 'autocmd-lua'
local autocmds = {}
for _, auto in ipairs(autos) do
local events = auto.event
if type(auto.event) == "string" then
events = { auto.event }
end
for _, e in ipairs(events) do
table.insert(autocmds, { event = e, pattern = auto.pattern, cmd = auto.command })
end
end
poly.augroup {
group = group,
autocmds = autocmds,
}
end
local autocmd = __builtin_support and builtin or polyfill
function M.new()
local m = {}

View File

@ -1,108 +0,0 @@
---@class psoxizsh.entrypoint.config
local M = {}
---@class PsoxizshConfig
---@field profile string|PsoxizshConfigProfileCb|nil The stock profile to apply to the config
---@field keybinds PsoxizshConfigKeysCb|nil A callback to allow users to set the PsoxizshKeyBinds
---@field lazy LazyConfig|nil The configuration passed to our package manager
---@alias PsoxizshConfigKeysCb fun(keys: PsoxizshKeyBinds):nil
---@alias PsoxizshConfigProfileCb fun(config: PsoxizshConfig):nil
---Default PsoxizshConfig
---@return PsoxizshConfig
local defaults = function()
return {
lazy = {
spec = {
{ 'LazyVim/LazyVim',
import = 'lazyvim.plugins',
priority = 10000
},
{ 'psoxizsh',
import = 'psoxizsh.plugins',
priority = 09999,
dir = os.getenv('PSOXIZSH') .. '/nvim',
lazy = false,
opts = {},
config = function(_, opts) require('psoxizsh').setup(opts) end
},
{ import = 'plugins' },
},
defaults = {
lazy = false,
version = false,
keymaps = false,
},
install = {
colorscheme = {
'onedark', 'tokyonight', 'habamax',
}
},
checker = {
enabled = true,
concurrency = math.max(vim.uv.available_parallelism() - 2, 2),
frequency = 60 * 60 * 8, -- 8 hours
},
performance = {
rtp = {
disabled_plugins = {
-- 'gzip',
-- 'matchit',
-- 'matchparen',
'netrwPlugin',
-- 'tarPlugin',
'tohtml',
'tutor',
-- 'zipPlugin',
},
},
},
},
keybinds = function() --[[ don't override keybinds by default ]] end,
}
end
---Fetch the current PsoxizshConfig table
---@return PsoxizshConfig
function M.get()
if not M._lazy_config then
M._lazy_config = defaults()
end
return M._lazy_config
end
---Merge the given overrides into the current PsoxizshConfig
---@param overrides? PsoxizshConfig|PsoxizshConfigProfileCb
function M.set(overrides)
if type(overrides) == 'nil' then return end
if type(overrides) == 'function' then
M._lazy_config = overrides(M.get())
return
end
if type(overrides) == 'table' then
M._lazy_config = vim.tbl_deep_extend('force', M.get(), overrides)
return
end
vim.notify_once(
'config provided was neither a function or table, ignoring',
vim.log.levels.WARN,
{ title = 'psoxizsh.entrypoint' }
)
end
---Merge the given overrides into the current PsoxizshConfig, returning it
---@param overrides? PsoxizshConfig|PsoxizshConfigProfileCb
---@return PsoxizshConfig
function M.with(overrides)
M.set(overrides)
return M.get()
end
return M

View File

@ -1,56 +0,0 @@
---@class psoxizsh.entrypoint
local M = {}
local add_lazy_rtp = function()
if _G._psoxizsh_entrypoint_add_lazy_rtp == 1 then
return
end
vim.opt.rtp:prepend(os.getenv('PSOXIZSH') .. '/nvim/lazy.nvim')
_G._psoxizsh_entrypoint_add_lazy_rtp = 1
end
---Called the keybind callback, if any
---@param fn? PsoxizshConfigKeysCb
local set_keybinds = function(fn)
if type(fn) == 'function' then
fn(require('psoxizsh.key.binds'))
end
end
---Set the active profile (if any)
---@param profile? string|PsoxizshConfigProfileCb
---@param config PsoxizshConfig
local set_profile = function(profile, config)
if not profile then return end
if type(profile) == 'function' then
profile(config)
end
if type(profile) == 'string' then
if profile == 'psox' or profile == 'bazaah' then
require(('psoxizsh.entrypoint.profile.%s'):format(profile))(config)
end
end
end
---Begin Psoxizsh NeoVim initalization, with the default config
function M.start()
M.start_with(nil)
end
---Begin Psoxizsh NeoVim initalization with the given overrides
---@param overrides? PsoxizshConfig|PsoxizshConfigProfileCb
function M.start_with(overrides)
local config = require('psoxizsh.entrypoint.config').with(overrides)
add_lazy_rtp()
set_profile(config.profile, config)
set_keybinds(config.keybinds)
require('lazy').setup(config.lazy)
end
return M

View File

@ -1 +0,0 @@
return function(_) end

View File

@ -1,16 +0,0 @@
local function psox_keybinds()
local keys = require 'psoxizsh.key.binds'
-- Use Ctrl-Shift-<Arrow> for movement
keys.Global.NavigateUp.Key = '<C-S-Up>'
keys.Global.NavigateLeft.Key = '<C-S-Left>'
keys.Global.NavigateRight.Key = '<C-S-Right>'
keys.Global.NavigateDown.Key = '<C-S-Down>'
end
local function psox(config)
config.keybinds = psox_keybinds
end
return psox

View File

@ -1,35 +0,0 @@
-- Top level functions to be used in key binds and commands
local M, S = {}, {}
---Toggle the line numbers and diagnostic gutter
function M.ToggleGutter()
local o, diagnostic = vim.opt, vim.diagnostic
if o.number:get() then
S.signcolumn = o.signcolumn:get()
o.number = false
o.relativenumber = false
o.signcolumn = 'no'
diagnostic.enable(false)
else
o.number = true
o.relativenumber = true
o.signcolumn = S.signcolumn or 'yes:1'
diagnostic.enable(true)
end
vim.cmd 'IBLToggle'
end
---Open a float with your local config files
function M.OpenConfig()
return LazyVim.pick.config_files()()
end
---Format the active selection or buffer
function M.Format()
return LazyVim.format { force = true }
end
return M

View File

@ -1,18 +1,196 @@
local o, g, fn, cmd = vim.opt, vim.g, vim.fn, vim.cmd
local au, util = require 'psoxizsh.autocmd', require 'psoxizsh.util'
---@class psoxizsh
local M = {}
local function psoxizsh_early_config()
-- Local early configuration
util.try_mreload('early')
---Initialize Psoxizsh NeoVim
---@param _ table|nil
function M.setup(_)
local startup = require 'psoxizsh.startup'
local au = require 'psoxizsh.autocmd'
-- Set global color scheme var
if not g.my_color_scheme then
g.my_color_scheme = 'one'
end
startup.pre()
startup.early()
-- Hide buffers don't close them
o.hidden = true
LazyVim.on_very_lazy(startup.post)
LazyVim.on_very_lazy(startup.late)
-- Sane pane opening
o.splitbelow = true
o.splitright = true
-- File indent opts
o.encoding = "utf-8"
o.shiftwidth = 2
o.tabstop = 8
o.softtabstop = 2
o.expandtab = true
o.list = true
o.listchars:append {
trail = '\u{02FD}',
extends = '\u{22B3}',
precedes = '\u{22B2}',
nbsp = '\u{02EC}',
conceal = '\u{2219}',
tab = '\u{2559}\u{254C}\u{2556}',
}
o.ignorecase = true
o.infercase = true
cmd 'filetype plugin indent on'
-- Set completion messages off
o.shortmess:append { c = true }
-- Preview window + menu for autocompletions
o.completeopt:append {
'preview',
'menuone',
'longest',
}
-- Lower update time (Default 4000)
o.updatetime = 300
-- Numbered lines
o.number = true
o.relativenumber = true
o.signcolumn = 'yes:1'
-- Disable '--INSERT--' and friends
o.showmode = false
-- Use existing buffers
o.switchbuf = { "useopen", "usetab" }
-- Set global statusline (0.7+ only)
if fn.has('nvim-0.7') == 1 then o.laststatus = 3 end
-- Local pre plugin configuration
util.try_mreload('pre')
end
return M
-- Load plugins
local function psoxizsh_post_config(plugs)
local vimp = require 'vimp'
-- Local post plugin configuration
util.try_mreload('post')
-- Setup file backups
cmd ':silent !mkdir -p ~/.vimbackup'
o.backupdir = fn.expand('~') .. '/.vimbackup'
o.directory = fn.expand('~') .. '/.vimbackup'
o.hlsearch = true
-- ripgrep settings
g.rg_highlight = 'true'
g.rg_derive_root = 'true'
-- Other
g.rainbow_active = 1
au.PsoxFileAutos {
{ 'FileType', 'yaml', 'setlocal indentkeys-=<:> ts=8 sts=2 sw=2 expandtab' },
{ 'FileType', 'go', 'setlocal ts=8 sts=4 sw=4 noexpandtab' },
{ 'FileType', 'quickfix,netrw', 'setlocal nobuflisted' },
{ 'FileType', 'netrw', function() require('vimp').nmap({'buffer', 'silent'}, '<ESC>', ':call CloseNetrw()<CR>') end },
}
cmd([[
function! CloseNetrw() abort
for bufn in range(1, bufnr('$'))
if bufexists(bufn) && getbufvar(bufn, '&filetype') ==# 'netrw'
silent! execute 'bwipeout ' . bufn
if getline(2) =~# '^" Netrw '
silent! bwipeout
endif
return
endif
endfor
endfunction
]])
if plugs:has('fzf') then
if fn.executable('rg') == 1 then
vimp.nnoremap('<A-g>', ':Rg ')
vimp.nnoremap('<leader><A-g>', ':Rg! ')
vimp.nnoremap({'silent'}, '<A-S-g>', ':Rg<CR>')
vimp.nnoremap({'silent'}, '<leader><A-S-g>', ':Rg!<CR>')
end
vimp.nnoremap('<A-f>', ':Files ')
vimp.nnoremap('<leader><A-f>', ':Files! ')
vimp.nnoremap({'silent'}, '<A-S-f>', ':Files<CR>')
vimp.nnoremap({'silent'}, '<leader><A-S-f>', ':Files!<CR>')
vimp.nnoremap('<A-b>', ':Buffers ')
vimp.nnoremap('<leader><A-b>', ':Buffers! ')
vimp.nnoremap({'silent'}, '<A-S-b>', ':Buffers<CR>')
vimp.nnoremap({'silent'}, '<leader><A-S-b>', ':Buffers!<CR>')
end
-- Workaround for writing readonly files
vimp.cnoremap({'silent'}, 'w!!', 'w !sudo tee % >/dev/null')
-- Open any known user configuration paths for editing
vimp.nnoremap({'silent'}, '<leader>ve', function()
local rtp = vim.fn.join(o.runtimepath:get(), ',')
local files = {
early = vim.fn.globpath(rtp, '/lua/early.lua', 0, 1)[1] or nil,
pre = vim.fn.globpath(rtp, '/lua/pre.lua', 0, 1)[1] or nil,
post = vim.fn.globpath(rtp, '/lua/post.lua', 0, 1)[1] or nil,
late = vim.fn.globpath(rtp, '/lua/late.lua', 0, 1)[1] or nil,
my = os.getenv("MYVIMRC") or nil,
}
for _, file in pairs(files) do
if vim.fn.filereadable(file) == 1 then
cmd('edit ' .. file)
end
end
end)
-- Toggles all gutter items
vimp.nnoremap({'silent'}, '<leader>N', function()
if o.number:get() then
o.number = false
o.relativenumber = false
o.signcolumn = 'no'
else
o.number = true
o.relativenumber = true
o.signcolumn = 'yes:1'
end
end)
-- Reload configuration
vimp.nnoremap('<leader>vs', function() vimp.unmap_all() plugs:reload() end)
o.background = 'dark'
o.termguicolors = true
g.one_allow_italics = 1
cmd('highlight Comment term=italic cterm=italic gui=italic')
end
local function psoxizsh_late_config(_)
-- Local late configuration
util.try_mreload('late')
-- Rest of config below is specifically not user override-able
o.exrc = true
o.secure = true
o.modeline = true
o.modelines = 7
end
local hooks = {
early = { 'PsoxConfigEarly', psoxizsh_early_config },
post = { 'PsoxConfigPost', psoxizsh_post_config },
late = { 'PsoxConfigLate', psoxizsh_late_config },
}
return require('psoxizsh.plugins') { hooks = hooks }

View File

@ -1,117 +0,0 @@
local core = require 'psoxizsh.key.core'
---@alias PsoxizshKeyBinds psoxizsh.key.binds
---@class psoxizsh.key.binds
local M = {}
local B = core.mkbind
-- ############################
-- ## GLOBAL BINDINGS ##
-- ############################
M.Global = {
-- ############
-- ## Supers ##
-- ############
--
Super = {
FileBrowser = B { '<C-Left>' , '<cmd>Neotree toggle reveal position=left<CR>' , desc = 'Toggle File Browser' , } ,
FuzzySearch = B { '<C-Right>' , '<cmd>Telescope builtin<CR>' , desc = 'Activate Telescope fuzzy finder' , } ,
Terminal = B { '<C-Up>' , '<cmd>ToggleTerm<CR>' , desc = 'Open terminal in a float' , } ,
Diagnostics = B { '<C-Down>' , '<cmd>TroubleToggle<CR>' , desc = 'Open workspace diagnostics' , } ,
},
-- ##############
-- ## <Leader> ##
-- ##############
--
Format = B { '<Leader>F' , desc = 'Format selection or buffer' , } ,
OpenConfig = B { '<Leader>ve' , desc = 'Open user Neovim configuration files' , } ,
ReloadConfig = B { '<Leader>vs' , desc = 'Reload Neovim configuration' , } ,
ToggleGutter = B { '<Leader>N' , desc = 'Toggle Neovim gutter' , } ,
ToggleBuffers = B { '<Leader><Tab>' , desc = 'Open buffer list' , } ,
ToggleGitStatus = B { '<Leader>gs' , desc = 'Open Git status float' , } ,
-- ################
-- ## Navigation ##
-- ################
--
-- Tmux interplay
NavigateLeft = B { '<C-h>', desc = 'Navigate left one window' , } ,
NavigateDown = B { '<C-j>', desc = 'Navigate down one window' , } ,
NavigateUp = B { '<C-k>', desc = 'Navigate up one window' , } ,
NavigateRight = B { '<C-l>', desc = 'Navigate right one window' , } ,
--
-- Buffer movement
--
BufferNext = B { '<Tab>' , desc = 'Next buffer or tab' , } ,
BufferPrev = B { '<S-Tab>' , desc = 'Previous buffer or tab' , } ,
--
-- Diagnostics
--
DiagnosticNext = B { ']g' , desc = 'Next buffer diagnostic' , } ,
DiagnosticPrev = B { '[g' , desc = 'Previous buffer diagnostic' , } ,
-- #####################
-- ## Auto completion ##
-- #####################
--
AutoComplete = {
Trigger = B { '<C-Space>' , desc = 'Request completion at <cword>' , } ,
Abort = B { '<C-CR>' , desc = 'Abort active completion' , } ,
Confirm = B { '<CR>' , desc = 'Select active completion' , } ,
Next = B { '<Tab>' , desc = 'Next completion entry' , } ,
Prev = B { '<S-Tab>' , desc = 'Previous completion entry' , } ,
ScrollUp = B { '<PageUp>' , desc = 'Scroll up completion entry documentation' , } ,
ScrollDown = B { '<PageDown>' , desc = 'Scroll down completion entry documentation' , } ,
},
SudoWrite = B { 'w!!' , desc = 'Sudo write the current file' , mode = 'c' } ,
}
-- ############################
-- ## BUFFER BINDINGS ##
-- ############################
M.Buffer = {
-- ###################
-- ## LSP on_attach ##
-- ###################
--
Lsp = {
LspInfo = B { '<Leader>Ci' , desc = 'Language Server Information' , } ,
RenameSymbol = B { '<Leader>rn' , desc = 'Rename <cword>' , } ,
RenameFile = B { '<Leader>rF' , desc = 'Rename the current file' , } ,
ShowDocumentation = B { 'K' , desc = 'Display documentation of <cword>' , } ,
ShowSignature = B { '<Leader>K' , desc = 'Display function signature help of <cword>' , } ,
ShowReferences = B { '<Leader>Cr' , desc = 'Display all references to <cword>' , } ,
CodeAction = B { '<Leader>.' , desc = 'Request code actions for <cword>' , } ,
SourceAction = B { '<Leader>Ca' , desc = 'Request source actions for <cword>' , } ,
GotoDefinition = B { 'gd' , desc = 'Jump to definition of <cword>' , } ,
GotoTypeDefinition = B { 'gT' , desc = 'Jump to type definition of <cword>' , } ,
GotoImplementation = B { 'gI' , desc = 'Jump to implementation of <cword>' , } ,
GotoDeclaration = B { 'gD' , desc = 'Jump to declaration of <cword>' , } ,
CodelensDisplay = B { '<Leader>>' , desc = 'Refresh & Display Codelens' , } ,
CodelensRun = B { '<Leader>r>' , desc = 'Run Codelens at <cword>' , } ,
ReferenceNext = B { ']]' , desc = 'Next reference' , } ,
ReferencePrev = B { '[[' , desc = 'Previous reference' , } ,
},
}
-- ############################
-- ## PLUGIN BINDINGS ##
-- ############################
M.Plugin = {
-- ###################
-- ## dressing.nvim ##
-- ###################
--
Dressing = {
Close = B { '<Esc>' , desc = 'Close the input modal' , mode = 'i' , } ,
Confirm = B { '<CR>' , desc = 'Submit the current input' , mode = 'i' , } ,
Prev = B { '<Up>' , desc = 'Previous item in input history' , mode = 'i' , } ,
Next = B { '<Down>' , desc = 'Next item in input history' , mode = 'i' , } ,
},
}
return M

View File

@ -1,118 +0,0 @@
local M = {}
--- A key bind.
---
--- Each Bind object represents a single key binding that can be registered with Neovim.
---@class PsoxizshKeyBind
---
---@field __struct 'PsoxizshKeyBind' Class identifier
---@field Key string Key that will be bound
---@field Mode string|string[] Mode(s) of the keybind, defaults to 'n' if unset
---@field Desc string|nil Description of the keybind
---@field Action string|function|nil Action to bind to `self.key`. May be a string, which will be interpreted as vimscript or a lua function
---@field opts PsoxizshKeyBindOpts|nil Set of options for this keybind -- not all options will apply to all call sites
---@field as fun(self: PsoxizshKeyBind, args: { [1]: PsoxizshKeyAsType }|PsoxizshKeyArgs): table
---@field _as_lazy fun(self: PsoxizshKeyBind, overrides?: PsoxizshKeyArgs): LazyKeysSpec
--- A set of `vim.keymap.set` {opts}.
---
--- See :h vim.keymap.set and :h map-arguments for details
---@class PsoxizshKeyBindOpts
---
---@field noremap boolean|nil Defaults to true
---@field remap boolean|nil Opposite of noremap (overrides, if set)
---@field nowait boolean|nil Defaults to false
---@field silent boolean|nil Defaults to true
---@field script boolean|nil Defaults to false
---@field expr boolean|nil Defaults to false
---@field unique boolean|nil Defaults to false
---@field buffer number|nil Defaults to false
---@class PsoxizshNewKeyBindArgs
---
---@field [1] string|nil The key pattern to use, alternative to `self.key`
---@field [2] string|function|nil The action to take; if applicable, alternative to `self.action`
---@field key string|nil The key pattern to use
---@field action string|function|nil The action to take; if applicable
---@field desc string|nil The description for this key bind
---@field mode string|string[]|nil The mode(s) to apply this key bind in
---@alias PsoxizshKeyArgs PsoxizshNewKeyBindArgs|PsoxizshKeyBindOpts
---@alias PsoxizshKeyAsType 'lazy'
local Bind = {
__struct = 'PsoxizshKeyBind',
}
---Create a new PsoxizshKeyBind
---@param key string
---@param action string|function|nil
---@param desc string|nil
---@param mode string|string[]
---@param opts PsoxizshKeyBindOpts|nil
function Bind.new(key, action, desc, mode, opts)
local this = vim.deepcopy(Bind)
this.Key = key
this.Action = action
this.Desc = desc
this.Mode = mode
this.opts = opts
return this
end
---Convert this PsoxizshKeyBind into another key bind format `type`
---@param self PsoxizshKeyBind
---@param args { [1]: PsoxizshKeyAsType }|PsoxizshKeyArgs
---@return table
function Bind.as(self, args)
local type = table.remove(args, 1)
if type == 'lazy' then return self:_as_lazy(args) end
return {}
end
---Convert this PsoxizshKeyBind into a LazyKeysSpec
---@param self PsoxizshKeyBind
---@param overrides? PsoxizshKeyArgs
---@return LazyKeysSpec
function Bind._as_lazy(self, overrides)
local args = overrides or {}
local key = args.key or args[1] or self.Key ; args.key = nil ; args[1] = nil
local action = args.action or args[2] or self.Action ; args.action = nil ; args[2] = nil
local desc = args.desc or self.Desc ; args.desc = nil
local mode = args.mode or self.Mode ; args.mode = nil
if mode == 'n' then mode = nil end ---@diagnostic disable-line: cast-local-type
local opts = vim.tbl_extend('force', self.opts or {}, args)
return { key, action, desc = desc, mode = mode, unpack(opts) }
end
---Create a new @PsoxizshKeyBind from the provided `opts`
---@param opts PsoxizshNewKeyBindArgs|PsoxizshKeyBindOpts
---@return PsoxizshKeyBind|nil
function M.mkbind(opts)
local key = opts[1] or opts.key
local action = opts[2] or opts.action
local mode = opts.mode or 'n'
local kopts = {
noremap = opts.noremap,
remap = opts.remap,
nowait = opts.nowait,
silent = opts.silent,
script = opts.script,
expr = opts.expr,
unique = opts.unique,
buffer = opts.buffer,
}
if not key then return nil end
return Bind.new(key, action, opts.desc, mode, next(kopts) ~= nil and kopts or nil)
end
return M

View File

@ -1,11 +0,0 @@
local core, binds = require 'psoxizsh.key.core', require 'psoxizsh.key.binds'
---@class psoxizsh.key
local M = {}
M.binds = binds
M.fn = {}
M.fn.mkbind = core.mkbind
return M

View File

@ -1,95 +0,0 @@
---@class PsoxizshLspServer
---@field id string The canonical name of the server
---@field specs LazySpec Any other LazySpecs that will be included with ours
---@field opts PsoxizshLspServerConfig This spec's config
---@field callback PsoxizshLspPresetCallback Converts self.opts into a LazySpec
---@field get fun(self: PsoxizshLspServer): LazySpec Return the materialized LazySpec for this server
---@field with fun(self: PsoxizshLspServer, opts: PsoxizshLspServerConfig): LazySpec Return the materialized LazySpec for this server, with the given opts merged in
---@operator call(PsoxizshLspServerConfig|nil): LazySpec
---@class PsoxizshLspServerConfig
---@field settings table The lspconfig settings for this server
---@alias PsoxizshLspPresetCallback fun(string, PsoxizshLspServerConfig): LazySpec
---@class psoxizsh.lsp.core
local M = {}
local S = {}
---Merge the provided config into the normal neovim/nvim-lspconfig structure
---@param server string
---@param config table
---@return table
function M.make_server(server, config)
return { servers = { [server] = config } }
end
---Create a LazyPlugin spec override for neovim/nvim-lspconfig for the given
---server and config
---@param server string
---@param opts PsoxizshLspServerConfig
---@return LazySpec
function M.lspconfig_server(server, opts)
return {
'neovim/nvim-lspconfig', opts = M.make_server(server, opts.settings)
}
end
---Create a new LSP server spec
---@param id string
---@param inherit LazySpec
---@param cb PsoxizshLspPresetCallback
---@return PsoxizshLspServer
function M.preset(id, inherit, cb)
return S.new(id, inherit, cb)
end
---Create a new PsoxizshLspServer
---@param id string
---@param specs LazySpec
---@param cb PsoxizshLspPresetCallback
---@return PsoxizshLspServer
function S.new(id, specs, cb)
local this = vim.deepcopy(S)
this.id = id
this.specs = specs
this.callback = cb
this.opts = { settings = {} }
setmetatable(this, {
__call = function(self, opts)
local hasopts = type(opts) == 'table' and next(opts) ~= 'nil' or type(opts) ~= 'nil'
return hasopts and self:with(opts) or self:get()
end
})
return this
end
---Get the LazyVim plugin spec(s) for this LspServer
---@param self PsoxizshLspServer
---@return LazySpec
function S.get(self)
local unpack = table.unpack or unpack
local specs = type(self.specs) == 'string' and {{ import = self.specs }} or self.specs
local lsp = self.callback(self.id, self.opts)
return { unpack(specs), lsp }
end
---Get the LazyVim plugin spec(s) for this LspServer
---@param self PsoxizshLspServer
---@param opts PsoxizshLspServerConfig
---@return LazySpec
function S.with(self, opts)
local this = vim.deepcopy(self)
this.opts = vim.tbl_deep_extend('force', this.opts, opts)
return this:get()
end
return M

View File

@ -1,54 +0,0 @@
-- Keys for LSP on_attach functionality
--
-- These are for generic / language server independent functions, see the below
-- link for how to add key binds for specific LSPs.
--
-- https://www.lazyvim.org/configuration/keymaps#lsp-server-keymaps
local function rebind(args)
local target, bind = args[1], args[2]
-- Do nothing if given a nil bind
if type(bind) == 'nil' then return end
-- Disable (but keep) the bind if given a false bind
if type(bind) == 'boolean' and not bind then
target[2] = false ; return
end
-- Otherwise, set key pattern and description
target[1] = bind.Key
if bind.Desc then target.desc = bind.Desc end
end
return {
{ 'neovim/nvim-lspconfig',
opts = function(_, _)
local keys = require('psoxizsh.key.binds').Buffer.Lsp
local K = require("lazyvim.plugins.lsp.keymaps").get()
-- So this is a bit obtuse to set, because we have to match the order
-- provided by LazyVim, see the following for the offsets
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/lsp/keymaps.lua#L15
rebind { K[1], keys.LspInfo } -- 'Lsp Info'
rebind { K[2], keys.GotoDefinition } -- 'Goto Definition'
rebind { K[3], keys.ShowReferences } -- 'References'
rebind { K[4], keys.GotoImplementation } -- 'Goto Implementation'
rebind { K[5], keys.GotoTypeDefinition } -- 'Goto Type Definition'
rebind { K[6], keys.GotoDeclaration } -- 'Goto Declaration'
rebind { K[7], keys.ShowDocumentation } -- 'Hover'
rebind { K[8], keys.ShowSignature } -- 'Signature Help'
rebind { K[9], false } -- 'Signature Help' (disable insert mode map)
rebind { K[10], keys.CodeAction } -- 'Code Action'
rebind { K[11], keys.CodelensRun } -- 'Run Codelens'
rebind { K[12], keys.CodelensDisplay } -- 'Refresh & Display Codelens'
rebind { K[13], keys.RenameFile } -- 'Rename File'
rebind { K[14], keys.RenameSymbol } -- 'Rename'
rebind { K[15], keys.SourceAction } -- 'Source Action'
rebind { K[16], keys.ReferenceNext } -- 'Next Reference'
rebind { K[17], keys.ReferencePrev } -- 'Prev Reference'
rebind { K[18], false } -- 'Next Reference' (disable alt map)
rebind { K[19], false } -- 'Prev Reference' (disable alt map)
end
},
}

View File

@ -1,66 +0,0 @@
-- Language Server presets based off of LazyVim's extras.lang plugin sets
--
-- You can use these in your plugin/* files via calling them in a plugin spec.
--
-- For example:
--
-- ```lua
-- local Server = require 'psoxizsh.lsp.preset'
--
-- return { Server.Yaml(), Server.Json(), Server.Rust:with { checkOnSave = true } }
-- ```
local core = require 'psoxizsh.lsp.core'
---@class psoxizsh.lsp.preset
local M = {}
M.Ansible = core.preset('ansiblels', 'lazyvim.plugins.extras.lang.ansible', core.lspconfig_server)
M.Awk = core.preset('awklsp', {}, core.lspconfig_server)
M.Bazel = core.preset('bzl', {}, core.lspconfig_server)
M.Clang = core.preset('clangd', 'lazyvim.plugins.extras.lang.clangd', core.lspconfig_server)
M.CMake = core.preset('neocmake', 'lazyvim.plugins.extras.lang.cmake', core.lspconfig_server)
M.Docker = core.preset('dockerls', 'lazyvim.plugins.extras.lang.docker', core.lspconfig_server)
M.Elixir = core.preset('elixirls', 'lazyvim.plugins.extras.lang.elixir', core.lspconfig_server)
M.Go = core.preset('gopls', 'lazyvim.plugins.extras.lang.go', core.lspconfig_server)
M.Git = core.preset('_git_placeholder_', 'lazyvim.plugins.extras.lang.git', function(_, _) return nil end)
M.Json = core.preset('jsonls', 'lazyvim.plugins.extras.lang.json', core.lspconfig_server)
M.Lua = core.preset('lua_ls', {}, core.lspconfig_server)
M.Markdown = core.preset('marksman', 'lazyvim.plugins.extras.lang.markdown', core.lspconfig_server)
M.Perl = core.preset('perlnavigator', {}, core.lspconfig_server)
M.Php = core.preset('phpactor', 'lazyvim.plugins.extras.lang.php', core.lspconfig_server)
M.Python = core.preset('pyright', 'lazyvim.plugins.extras.lang.python', core.lspconfig_server)
M.Rust = core.preset('rust-analyzer', 'lazyvim.plugins.extras.lang.rust', function(server, opts)
return {
'mrcjkb/rustaceanvim',
opts = {
server = { default_settings = { [server] = opts.settings } }
}
}
end)
M.Terraform = core.preset('terraformls', 'lazyvim.plugins.extras.lang.terraform', core.lspconfig_server)
M.Toml = core.preset('taplo', 'lazyvim.plugins.extras.lang.toml', core.lspconfig_server)
M.TypeScript = core.preset('vtsls', 'lazyvim.plugins.extras.lang.typescript', core.lspconfig_server)
M.JavaScript = M.TypeScript
M.Yaml = core.preset('yamlls', 'lazyvim.plugins.extras.lang.yaml', core.lspconfig_server)
return M

View File

@ -0,0 +1,24 @@
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
local repo_url = 'https://github.com/wbthomason/packer.nvim'
local strapped = nil
-- Bootstraps our package manager, ensuring it is present on the local system
local function bootstrap()
local should_install = fn.empty(fn.glob(install_path)) > 0
if should_install then
fn.system({'git', 'clone', '--depth', '1', repo_url, install_path})
end
return should_install
end
if not strapped then
strapped = bootstrap()
end
return function()
return strapped
end

View File

@ -1,20 +0,0 @@
return {
{ 'catppuccin', enabled = false }, -- disable LazyVim default colorscheme
{ 'olimorris/onedarkpro.nvim',
priority = 1000,
opts = {
plugins = { all = true },
styles = {
comments = 'italic',
},
options = {
bold = true,
italic = true,
underline = true,
undercurl = true,
},
},
},
}

View File

@ -0,0 +1,23 @@
return function()
local bl, vimp, util = require 'bufferline', require 'vimp', require 'psoxizsh.util'
local defaults = {
always_show_bufferline = true,
numbers = "none",
diagnostics = 'coc',
offsets = {{
filetype = 'neo-tree',
text = 'File Explorer',
text_align = 'center'
}},
show_buffer_close_icons = false,
separator_style = { '\u{E0B0}', '\u{E0B1}' },
sort_by = 'relative_directory',
}
bl.setup (util.mconfig('config.bufferline', { options = defaults }))
vimp.nnoremap({'silent'}, '<TAB>', ':BufferLineCycleNext<CR>')
vimp.nnoremap({'silent'}, '<S-TAB>', ':BufferLineCyclePrev<CR>')
vimp.nnoremap({'silent'}, '<leader><TAB>', ':BufferLinePick<CR>')
end

View File

@ -0,0 +1,74 @@
return function()
local fn, o, g = vim.fn, vim.opt, vim.g
local vimp, au = require 'vimp', require 'psoxizsh.autocmd'
local t = function(s)
return vim.api.nvim_replace_termcodes(s, true, true, true)
end
g['coc_global_extensions'] = {
'coc-yank',
'coc-spell-checker',
'coc-vimlsp',
'coc-rust-analyzer',
'coc-json',
'coc-markdownlint',
'coc-yaml'
}
-- Do action on current word
vimp.nmap({'silent'}, '<leader>.', '<Plug>(coc-codeaction-selected)w')
-- Do action on a selection
vimp.nmap({'silent'}, '<leader>/', '<Plug>(coc-codeaction-selected)')
vimp.xmap({'silent'}, '<leader>/', '<Plug>(coc-codeaction-selected)')
-- Rename symbol
vimp.nmap({'silent'}, '<leader>rn', '<Plug>(coc-rename)')
-- Goto definition / references
vimp.nmap({'silent'}, '<leader>gd', '<Plug>(coc-definition)')
vimp.nmap({'silent'}, '<leader>gr', '<Plug>(coc-references)')
-- Use tab for trigger completion with characters ahead and navigate.
-- NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
-- other plugin before putting this into your config.
vimp.inoremap({'silent', 'expr'}, '<TAB>', [[coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? "\<Tab>" : coc#refresh()]])
vimp.inoremap({'expr'}, '<S-TAB>', [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]])
vim.cmd [[
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
]]
-- Make <CR> to accept selected completion item or notify coc.nvim to format
-- <C-g>u breaks current undo, please make your own choice.
vimp.inoremap({'silent', 'expr'}, '<C-Space>', [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<C-r>=coc#on_enter()\<CR>"]])
-- Use `[g` and `]g` to navigate diagnostics
vimp.nmap({'silent'}, '[g', '<Plug>(coc-diagnostic-prev)')
vimp.nmap({'silent'}, ']g', '<Plug>(coc-diagnostic-next)')
if fn.has('nvim-0.4') then
-- Remap PageUp and PageDown for scroll float windows/popups.
vimp.nnoremap({'silent', 'nowait', 'expr'}, '<PageDown>', [[coc#float#has_scroll() ? coc#float#scroll(1) : "\<PageDown>"]])
vimp.nnoremap({'silent', 'nowait', 'expr'}, '<PageUp>', [[coc#float#has_scroll() ? coc#float#scroll(0) : "\<PageUp>"]])
end
-- Use K to show documentation in preview window.
local show_documentation = function()
return fn.CocAction('hasProvider', 'hover')
and fn.CocActionAsync('doHover')
or fn.feedkeys('K', 'in')
end
vimp.nnoremap({'silent'}, 'K', show_documentation)
-- Open yank list
vimp.nnoremap({'silent'}, '<C-Y>', t':<C-u>CocList -A --normal yank<CR>')
au.PsoxCocAutos {
{ 'CursorHold', '*', function() fn.CocActionAsync('highlight') end },
{ 'User', 'CocJumpPlaceholder', function() fn.CocActionAsync('showSignatureHelp') end },
}
end

View File

@ -0,0 +1,35 @@
return function()
local fn, o, api = vim.fn, vim.o, vim.api
if fn.executable('rg') == 1 then
-- Override the default grep implementation in vim
o.grepprg = 'rg --vimgrep --smart-case --follow'
if fn.has('nvim-0.7') == 1 then
-- Only search file contents, not file name
-- We can use the stock :Files for that
local rg_func = function(opts)
return fn['fzf#vim#grep'](
"rg --column --line-number --no-heading --color=always --smart-case " .. fn.shellescape(opts.args),
true,
fn['fzf#vim#with_preview']({options = '--delimiter : --nth 4..'}),
opts.bang
)
end
api.nvim_create_user_command('Rg', rg_func, { nargs = '*', bang = true })
-- If the user hasn't set a default FZF command, and has ripgrep installed,
-- use it over find, otherwise defer to the user's preferred command
if fn.empty(os.getenv('FZF_DEFAULT_COMMAND')) == 1 then
local files_func = function(opts)
return fn['fzf#vim#files'](
opts.args,
fn['fzf#vim#with_preview']({source = 'rg --files --hidden --glob "!**/.git/**" '}),
opts.bang
)
end
api.nvim_create_user_command('Files', files_func, { nargs = '?', bang = true, complete = 'dir' })
end
end
end
end

View File

@ -0,0 +1,12 @@
return function()
local gitsigns, util = require 'gitsigns', require 'psoxizsh.util'
local defaults = {
sign_priority = 100,
current_line_blame_formatter_opts = {
relative_time = false
},
}
gitsigns.setup(util.mconfig('config.gitsigns', defaults))
end

View File

@ -0,0 +1,65 @@
return function()
local ll, util, nwd = require 'lualine', require 'psoxizsh.util', require("nvim-web-devicons")
local file_color = function()
local _, color = nwd.get_icon_colors_by_filetype(vim.bo.filetype)
return { fg = color }
end
local diff_source = function()
-- May be nil if gitsigns hasn't populated yet
local gs = vim.b.gitsigns_status_dict or {}
return {
added = gs.added,
modified = gs.changed,
removed = gs.removed,
}
end
local filename = {
'filename',
icon = 'ƒ',
symbols = { modified = '|', readonly = '|', unnamed = '' },
color = file_color,
}
local branch = { 'branch', icon = '', color = { gui = 'bold,italic' } }
local diagnostics = { 'diagnostics', sources = { 'coc' }, update_in_insert = true }
local diff = { 'diff', source = diff_source }
local defaults = {
options = {
theme = 'auto',
icons_enabled = true,
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {},
always_divide_middle = true,
globalstatus = true,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'mode' },
lualine_b = { branch, diff, diagnostics },
lualine_c = { filename },
lualine_x = {'filetype', 'encoding', 'fileformat'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { filename },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
extensions = { 'fugitive', 'quickfix', 'man', 'fzf', 'neo-tree' }
}
ll.setup(util.mconfig('config.lualine', defaults))
end

View File

@ -0,0 +1,14 @@
return function()
local g, fn = vim.g, vim.fn
-- Don't move cursor into qf/loc on open
g.neomake_open_list = 2
-- Allow multiple makers to resolve
g.neomake_serialize = 1
g.neomake_serialize_abort_on_error = 1
-- Let Neomake control window size
g.qf_auto_resize = 0
fn['neomake#configure#automake']('rw', 800)
end

View File

@ -0,0 +1,162 @@
return function()
local g, fn = vim.g, vim.fn
local neotree, util, vimp = require 'neo-tree', require 'psoxizsh.util', require 'vimp'
local defaults = {
close_if_last_window = true,
enable_git_status = true,
default_component_configs = {
container = {
enable_character_fade = true
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "",
last_indent_marker = "",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "",
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon"
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
git_status = {
symbols = {
-- Change type
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
modified = "~", -- or "", but this is redundant info if you use git_status_colors on the name
deleted = "",-- this can only be used in the git_status source
renamed = "",-- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
},
},
window = {
position = "left",
width = 40,
mapping_options = {
noremap = true,
nowait = true,
},
mappings = {
["?"] = "show_help",
["q"] = "close_window",
["R"] = "refresh",
["<space>"] = { "toggle_node", nowait = false },
["<cr>"] = "open",
["S"] = "open_split",
["s"] = "open_vsplit",
["C"] = "close_node",
["z"] = "close_all_nodes",
["Z"] = "expand_all_nodes",
["X"] = "delete",
["r"] = "rename",
["a"] = { "add", config = { show_path = "relative" } },
["A"] = { "add_directory", config = { show_path = "relative" } },
["c"] = { "copy", config = { show_path = "relative" } },
["m"] = { "move", config = { show_path = "relative" } },
["y"] = "copy_to_clipboard",
["p"] = "paste_from_clipboard",
},
},
filesystem = {
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_hidden = true, -- only works on Windows for hidden files/directories
hide_by_name = { --[[ Example: 'node_modules' ]] },
hide_by_pattern = { --[[ Example '*.meta' ]] },
never_show = { --[[ remains hidden even if visible is toggled to true ]] },
},
follow_current_file = true, -- This will find and focus the file in the active buffer every
-- time the current file is changed while the tree is open.
group_empty_dirs = false, -- when true, empty folders will be grouped together
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_current", -- netrw disabled, opening a directory opens within the
-- window like netrw would, regardless of window.position
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
use_libuv_file_watcher = true, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = {
mappings = {
["<bs>"] = "navigate_up",
["."] = "set_root",
["H"] = "toggle_hidden",
["/"] = "fuzzy_finder",
["D"] = "fuzzy_finder_directory",
["f"] = "filter_on_submit",
["<c-x>"] = "clear_filter",
["[g"] = "prev_git_modified",
["]g"] = "next_git_modified",
},
},
},
buffers = {
follow_current_file = true, -- This will find and focus the file in the active buffer every
-- time the current file is changed while the tree is open.
group_empty_dirs = true, -- when true, empty folders will be grouped together
show_unloaded = true,
window = {
mappings = {
["X"] = "buffer_delete",
["<bs>"] = "navigate_up",
["."] = "set_root",
},
},
},
git_status = {
window = {
position = "float",
mappings = {
["A"] = "git_add_all",
["gu"] = "git_unstage_file",
["ga"] = "git_add_file",
["gr"] = "git_revert_file",
["gc"] = "git_commit",
["gp"] = "git_push",
["gg"] = "git_commit_and_push",
},
},
},
}
g['neo_tree_remove_legacy_commands'] = 1
fn.sign_define("DiagnosticSignError", {text = "", texthl = "DiagnosticSignError"})
fn.sign_define("DiagnosticSignWarn", {text = "", texthl = "DiagnosticSignWarn"})
fn.sign_define("DiagnosticSignInfo", {text = "", texthl = "DiagnosticSignInfo"})
fn.sign_define("DiagnosticSignHint", {text = "", texthl = "DiagnosticSignHint"})
vimp.nnoremap({'silent'}, '<F2>', ':Neotree toggle reveal position=left<CR>')
vimp.nnoremap({'silent'}, '<leader>gs', ':Neotree float git_status<CR>')
vimp.nnoremap({'silent'}, '<leader><S-TAB>', ':Neotree toggle reveal float source=buffers<CR>')
neotree.setup(util.mconfig('config.neotree', defaults))
end

View File

@ -0,0 +1,8 @@
return function()
local g = vim.g
-- Balance pairs when on open, close and delete
g.pear_tree_smart_openers = 1
g.pear_tree_smart_closers = 1
g.pear_tree_smart_backspace = 1
end

View File

@ -0,0 +1,11 @@
return function()
local g = vim.g
-- Don't force qf/loc windows to bottom
g.qf_window_bottom = 0
g.qf_loclist_window_bottom = 0
-- Let Neomake control window size
g.qf_auto_resize = 0
end

View File

@ -0,0 +1,11 @@
return function()
local g, vimp = vim.g, require 'vimp'
g['tmux_navigator_no_mappings'] = 1
g['tmux_navigator_disable_when_zoomed'] = 1
vimp.nnoremap({'override', 'silent'}, '<C-h>', ':TmuxNavigateLeft<CR>')
vimp.nnoremap({'override', 'silent'}, '<C-j>', ':TmuxNavigateDown<CR>')
vimp.nnoremap({'override', 'silent'}, '<C-k>', ':TmuxNavigateUp<CR>')
vimp.nnoremap({'override', 'silent'}, '<C-l>', ':TmuxNavigateRight<CR>')
end

View File

@ -1,9 +0,0 @@
-- Core / low level plugins used by others
return {
-- Community patch for Vim
{ 'tpope/vim-sensible', version = false, lazy = false },
-- Used in psoxizsh.* modules
{ 'nvim-lua/plenary.nvim', version = false, lazy = true },
}

View File

@ -1,146 +0,0 @@
local keys = require 'psoxizsh.key.binds'
return {
-- Disables search highlights when not searching
{ 'romainl/vim-cool', version = false, lazy = false },
-- Extends the '%' operator
{ 'andymass/vim-matchup', version = false, lazy = false },
-- Allows for per-window searches
{ 'mox-mox/vim-localsearch', version = false, lazy = false },
-- Comment helpers
{ 'scrooloose/nerdcommenter', version = false, lazy = false },
-- Text alignment
{ 'junegunn/vim-easy-align', version = false, lazy = false },
-- Pair () {} [], etc matching
{ 'tmsvg/pear-tree',
version = false,
lazy = false,
init = function(_)
-- Balance pairs when on open, close and delete
vim.g['pear_tree_smart_openers'] = 1
vim.g['pear_tree_smart_closers'] = 1
vim.g['pear_tree_smart_backspace'] = 1
-- Ignore Telescope windows
vim.g['pear_tree_ft_disabled'] = { 'TelescopePrompt' }
end,
},
{ 'echasnovski/mini.pairs', enabled = false }, -- We use pear-tree, disable LazyVim default
-- File browser
{ 'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'kyazdani42/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
opts = {
close_if_last_window = true,
enable_git_status = true,
filesystem = {
follow_current_file = { enabled = true },
}
},
keys = {
keys.Global.Super.FileBrowser:as { 'lazy', action = '<cmd>Neotree toggle reveal position=left<CR>' },
keys.Global.ToggleBuffers:as { 'lazy', action = '<cmd>Neotree toggle reveal float source=buffers<CR>' },
keys.Global.ToggleGitStatus:as { 'lazy', action = '<cmd>Neotree float git_status<CR>' },
},
},
-- Fuzzy search helpers
{ 'nvim-telescope/telescope.nvim',
branch = '0.1.x',
opts = {
defaults = {
mappings = { i = {
[keys.Global.Super.FuzzySearch.Key] = 'close'
}}
}
},
keys = {
keys.Global.Super.FuzzySearch:as { 'lazy', action = '<cmd>Telescope builtin<CR>' },
{ '<leader>,' , false },
}
},
-- Maker / diagnostics listing
{ 'folke/trouble.nvim',
dependencies = { 'kyazdani42/nvim-web-devicons' },
keys = {
keys.Global.Super.Diagnostics:as { 'lazy', action = '<cmd>Trouble diagnostics toggle<CR>' },
},
},
-- Terminal
{ 'akinsho/toggleterm.nvim',
version = '^2.0',
opts = {
open_mapping = keys.Global.Super.Terminal.Key,
start_in_insert = true,
insert_mappings = false,
terminal_mappings = true,
direction = 'float',
float_opts = { border = 'curved' },
},
keys = {
keys.Global.Super.Terminal:as { 'lazy', action = '<cmd>ToggleTerm<CR>' },
},
},
-- Tmux integration for pane movement
{ 'christoomey/vim-tmux-navigator',
cmd = { 'TmuxNavigateLeft', 'TmuxNavigateDown', 'TmuxNavigateUp', 'TmuxNavigateRight', 'TmuxNavigatePrevious' },
init = function(_)
vim.g['tmux_navigator_no_mappings'] = 1
vim.g['tmux_navigator_disable_when_zoomed'] = 1
end,
keys = {
keys.Global.NavigateUp:as { 'lazy', action = '<cmd>TmuxNavigateUp<CR>' },
keys.Global.NavigateLeft:as { 'lazy', action = '<cmd>TmuxNavigateLeft<CR>' },
keys.Global.NavigateRight:as { 'lazy', action = '<cmd>TmuxNavigateRight<CR>' },
keys.Global.NavigateDown:as { 'lazy', action = '<cmd>TmuxNavigateDown<CR>' },
},
},
-- Buffer management
{ 'qpkorr/vim-bufkill',
version = false,
lazy = false,
init = function(_)
-- We create these ourselves, with descriptions for which-key.nvim
vim.g['BufKillCreateMappings'] = 0
-- If the buffer you want to kill is in many windows,
-- the following option governs what to do.
--
-- default: 'confirm'
-- options: 'confirm' / 'kill' / 'cancel'
vim.g['BufKillActionWhenBufferDisplayedInAnotherWindow'] = 'confirm'
end,
keys = {
{ '<leader>bun' , '<Plug>BufKillBun' , desc = 'Unload Buffer' },
{ '<leader>!bun' , '<Plug>BufKillBangBun' , desc = 'Unload Buffer, force' },
{ '<leader>bd' , '<Plug>BufKillBd' , desc = 'Kill Buffer' },
{ '<leader>!bd' , '<Plug>BufKillBangBd' , desc = 'Kill Buffer, force' },
{ '<leader>bw' , '<Plug>BufKillBw' , desc = 'Wipeout Buffer' },
{ '<leader>!bw' , '<Plug>BufKillBangBw' , desc = 'Wipeout Buffer, force' },
{ '<leader>bundo' , '<Plug>BufKillUndo' , desc = 'Undo last Buffer action' },
},
},
-- Git integration
{ 'tpope/vim-fugitive', version = false, lazy = false },
-- Per project configuration
{ import = 'lazyvim.plugins.extras.lsp.neoconf' },
{ 'folke/neoconf.nvim',
version = '^1.0',
},
}

View File

@ -1,191 +0,0 @@
-- IDE components, autocompletion, DAPs
local keys = require 'psoxizsh.key.binds'
return {
-- Autocompletion + snippets + vim.diagnostic sources
-- Completion framework
{ 'hrsh7th/nvim-cmp',
dependencies = {
-- LSP sources
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lsp-signature-help',
-- Other sources:
{ url = 'https://codeberg.org/FelipeLema/cmp-async-path' },
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
'dmitmel/cmp-cmdline-history',
},
opts = function(_, opts)
local cmp = require('cmp')
local keys = keys.Global.AutoComplete ---@diagnostic disable-line: redefined-local
local auto_select = true
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end
opts.preselect = auto_select and cmp.PreselectMode.Item or cmp.PreselectMode.None
opts.completion = { completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect") }
opts.mapping = cmp.mapping.preset.insert({
[keys.Next.Key] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.snippet.active({ direction = 1 }) then
vim.schedule(function() vim.snippet.jump(1) end)
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
[keys.Prev.Key] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif vim.snippet.active({ direction = -1 }) then
vim.schedule(function() vim.snippet.jump(-1) end)
else
fallback()
end
end, { 'i', 's' }),
[keys.ScrollUp.Key] = cmp.mapping.scroll_docs(-4),
[keys.ScrollDown.Key] = cmp.mapping.scroll_docs(4),
[keys.Trigger.Key] = cmp.mapping.complete(),
[keys.Confirm.Key] = LazyVim.cmp.confirm({ select = auto_select }),
['<S-CR>'] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
[keys.Abort.Key] = function(fallback) cmp.abort() ; fallback() end,
})
-- Monkey patch the sources list LazyVim sets by default
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/coding.lua#L45-L50
local sources = {}
for _, src in ipairs(opts.sources) do
if src and src.name then
-- Insert function signature completions before LSP completions
if src.name == 'nvim_lsp' then
table.insert(sources, { name = 'nvim_lsp_signature_help' })
end
-- Replace path with async_path (less UI freezing)
if src.name == "path" then
table.insert(sources, { name = 'async_path' })
goto continue
end
-- Load completions from all open buffers
if src.name == 'buffer' then
table.insert(sources, { name = 'buffer', option = { get_bufnrs = vim.api.nvim_list_bufs } })
goto continue
end
end
table.insert(sources, src)
::continue::
end
opts.sources = sources
end
},
-- IDE stuff + language highlighting
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ 'neovim/nvim-lspconfig' },
{ import = 'psoxizsh.lsp.keys' },
{ 'vim-perl/vim-perl',
version = false,
ft = { 'perl' },
build = 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny'
},
{ 'rust-lang/rust.vim',
version = false,
ft = { 'rust' }
},
{ 'pearofducks/ansible-vim',
version = false,
ft = { 'yaml.ansible', 'yaml', 'yml.ansible', 'yml' }
},
{ 'kevinoid/vim-jsonc',
version = false,
},
{ 'luochen1990/rainbow',
version = false,
lazy = false,
init = function(_) vim.g['rainbow_active'] = 1 end,
},
{ 'sheerun/vim-polyglot', version = false, lazy = false, },
-- Framework for integrating non-LSP sources into nvim's LSP framework
{ import = 'lazyvim.plugins.extras.lsp.none-ls' },
{ 'nvimtools/none-ls.nvim',
opts = function(_, _)
LazyVim.on_very_lazy(function()
local lazyfmt = require 'lazyvim.util.format'
-- Remove the none-ls formatter, as we only want LazyVim to initialize
-- none-ls, not register it as a formatter
for i, formatter in ipairs(lazyfmt.formatters) do
if formatter.name == 'none-ls.nvim' then
table.remove(lazyfmt.formatters, i)
break
end
end
end)
end
},
{ 'nvimtools/none-ls.nvim',
dependencies = { 'davidmh/cspell.nvim' },
opts = function(_, opts)
if vim.fn.executable('cspell') == 0 then return end
-- CSpell setup
local cspell = require 'cspell'
local cspell_config_json = function(_)
return vim.fn.stdpath('config') .. '/cspell.json'
end
local cspell_opts = {
config = {
find_json = cspell_config_json,
on_add_to_json = function(payload)
if vim.fn.executable('jq') == 0 then return end
local p = payload.cspell_config_path
os.execute(string.format(
"jq -S '.words |= sort' %s > %s.tmp && mv %s.tmp %s",
p, p, p, p
))
end,
on_add_to_dictionary = function(payload)
if vim.fn.executable('sort') == 0 then return end
local p = payload.dictionary_path
os.execute(string.format('sort --dictionary-order %s -o %s', p, p))
end
},
diagnostics_postprocess = function(d)
local level, levels = d.severity, vim.diagnostic.severity
-- Cap maximum severity of spelling mistakes
if level == levels.ERROR or level == levels.WARN then
d.severity = levels.INFO
end
end,
}
-- Ensure our config file exists, otherwise cspell complains
local uv = (vim.uv or vim.loop);
if not uv.fs_stat(cspell_config_json()) then
vim.fn.writefile({'{}'}, cspell_config_json())
end
opts.sources = vim.tbl_extend('force', opts.sources or {}, {
cspell.diagnostics.with(cspell_opts),
cspell.code_actions.with(cspell_opts),
})
end,
},
}

View File

@ -1,13 +1,245 @@
local keys, fn = require 'psoxizsh.key.binds', require 'psoxizsh.functions'
local cmd, bootstrap, util = vim.cmd, require 'psoxizsh.plugins.bootstrap', require 'psoxizsh.util'
local cb_table = {}
local packer = nil
return {
{
'psoxizsh',
keys = {
keys.Global.Format:as { 'lazy', action = fn.Format },
keys.Global.ToggleGutter:as { 'lazy', action = fn.ToggleGutter },
keys.Global.OpenConfig:as { 'lazy', action = fn.OpenConfig },
keys.Global.SudoWrite:as { 'lazy', action = [[w !sudo tee % >/dev/null]] },
},
},
}
local EARLY, LATE = { early = 1, pre = 1 }, { post = 1, late = 1 }
-- Wrap the provided function in async context that will wait until all plugins have been initialized
local function defer_wrap(fn)
if bootstrap() then return fn end
return function(plugs)
local a = require 'plenary.async'
a.run(function()
-- Yield until packer's global plugin list is available
while _G.packer_plugins == nil do
a.util.sleep(100)
end
end, function()
fn(plugs)
end)
end
end
-- Plugins provides a hook based wrapper around packer.nvim, allowing
-- callers to register hooks at specific lifecycle events such as pre
-- and post plugin load.
--
-- A new, uninitialized one is provided upon requiring this module,
-- See :setup/1 and :init/0 for more on configuring and initializing
-- this object
local Plugins = { mt = {} }
-- Creates a new, uninitialized Plugins
--
-- You must call :init/0 (and likely :setup/1) before using this
-- object, though you can directly invoke the Plugins object as
-- you would :setup/1 as a convenience
function Plugins.new()
local m = {
_list = {},
_hooks = {},
}
setmetatable(m, Plugins.mt)
return m
end
-- Configures this Plugins, with the provided opts
--
-- You can provide a tables of hooks by name or { name, callback }
-- tuples.
--
-- In the former case, Plugins will create User <name> autocmds
-- when the lifecycle stage is hit, which you can register arbitrary
-- code to be invoked on.
--
-- In the latter, the provided callback fn will be invoked at the
-- lifecycle stage, with 'post' and 'late' hooks being provided the
-- current Plugins object as the first argument
--
-- @opts = {
-- hooks = {
-- early = name | { name, callback/0 }
-- pre = name | { name, callback/0 }
-- post = name | { name, callback/1 }
-- late = name | { name, callback/1 }
-- }
-- }
function Plugins.setup(self, opts)
opts = opts or {}
local hooks = opts.hooks or {}
self._hooks = vim.tbl_map(function(hk)
local t = type(hk)
if t == 'string' then return hk end
if t == 'table' then return hk[1] end
end, hooks)
local callbacks = vim.tbl_map(function(hk)
local t = type(hk[2])
if t == 'function' then return hk[2] end
end, hooks)
self:list_regen()
self:register_callbacks(callbacks)
return self
end
-- Invokes the plugin manager, and hooks any provided hooks as they become ready
--
-- Note, you shouldn't rerun this function, use :reload/0 instead if you want to
-- reload an existing Plugins
function Plugins.init(self)
self:do_hook 'early'
if packer == nil then
cmd [[packadd packer.nvim]]
packer = require 'packer'
packer.init {
max_jobs = 32
}
end
packer.reset()
self:do_hook 'pre'
for _, spec in ipairs(self:list()) do
packer.use(spec)
end
self:do_hook 'post'
self:do_hook 'late'
return self
end
-- Regenerate the plugin spec list, reloading the config if it has changed.
--
-- Note that this method *only* reloads the spec list, it does not reload
-- plugins, see :reload/0 for that
function Plugins.list_regen(self)
local plugs = util.mreload('psoxizsh.plugins.plug')
self._list = plugs(util.try_mconfig('plug'))
return self:list()
end
-- Return the current plugin list
function Plugins.list(self)
return self._list
end
-- Get the plugin spec for the provided @id.
--
-- The plugin id will be either the last component of the name, or if redefined by 'as',
-- whatever 'as' is.
--
-- Returns the spec if it exists, nil otherwise
function Plugins.get(self, id)
local needle = function(p)
local plugid = p.as and p.as or p[1] and p[1]:match("^.+/(.+)$")
return plugid == id
end
return vim.tbl_filter(needle, self:list())[1]
end
-- Check if the plugin @id exists in the current spec table
--
-- Returns true if it does, nil otherwise
function Plugins.has(self, id)
return self:get(id) and true or nil
end
-- Reload plugins, and rerun any registered hooks
function Plugins.reload(self)
self:list_regen()
self:init()
packer.compile()
end
-- Request the active Plugins to run the provided lifecycle's hook
--
-- Note that this may not run immediately, depending on current lifecycle
-- of underlying plugin manager
--
-- @name { 'early' | 'pre' | 'post' | 'late' }
function Plugins.do_hook(self, name)
if LATE[name] then
self:_post_hook(self._hooks[name])
elseif EARLY[name] then
self:_pre_hook(self._hooks[name])
end
end
-- Manually (re)register callbacks for any configured lifecycle hooks
--
-- Note that any hooks that were not registered in :setup/1 will be
-- silently ignored.
--
-- You may consider re-initializing the active Plugins via :setup/1:init/0
function Plugins.register_callbacks(self, callbacks)
_G._psoxizsh_plugins_cb = function(id) cb_table[id](self) end
cb_table = {}
cmd [[augroup PsoxConfigCallbacks]]
cmd [[autocmd!]]
for n, fn in pairs(callbacks) do
local id = self._hooks[n]
cb_table[id] = self:_make_callback(n, fn)
cmd(string.format('autocmd User %s call v:lua._psoxizsh_plugins_cb("%s")', id, id))
end
cmd [[augroup END]]
end
function Plugins._pre_hook(self, hook)
self:_dispatch_autocmd(hook)
end
function Plugins._post_hook(self, hook)
if bootstrap() and hook then
cmd [[augroup PsoxConfigBootstrap]]
cmd [[autocmd!]]
cmd [[autocmd VimEnter * ++once PackerSync]]
cmd [[augroup END]]
cmd ('augroup PsoxConfigDeferHook_' .. hook)
cmd ('autocmd!')
cmd ('autocmd User PackerCompileDone doautocmd User ' .. hook)
cmd ('augroup END')
else
self:_dispatch_autocmd(hook)
end
end
function Plugins._dispatch_autocmd(_, hook)
if hook then cmd('doautocmd User ' .. hook) end
end
function Plugins._make_callback(_, name, fn)
if LATE[name] then
return defer_wrap(fn)
else
return fn
end
end
-- Setup a convenience method for setting up + initializing a Plugins object
-- via directly calling the object with the opts that would normally be
-- provided to :setup/1
function Plugins.mt.__call(self, opts)
self:setup(opts):init()
end
-- Allow callers to access the underlying packer object
function Plugins.mt.__index(_, key)
return Plugins[key] or packer[key]
end
return Plugins.new()

View File

@ -0,0 +1,146 @@
local plugins = {
-- Allow packer to manage itself
{ 'wbthomason/packer.nvim',
opt = true,
cmd = 'Packer*',
module_pattern = { 'packer', 'packer%..*' }
},
-- Community patch for Vim
{ 'tpope/vim-sensible' },
-- Used in psoxizsh.* modules
{ 'nvim-lua/plenary.nvim' },
-- Utils for wrapping vimscript in lua easier
{ 'svermeulen/vimpeccable',
as = 'vimp'
},
-- Used for autocmds if we're not using a late enough version of neovim
{ 'jakelinnzy/autocmd-lua',
disable = vim.fn.has('nvim-0.7') == 1
},
-- Text alignment
{ 'junegunn/vim-easy-align' },
{ 'tmsvg/pear-tree',
config = require 'psoxizsh.plugins.config.pear-tree'
},
-- Git integration
{ 'tpope/vim-fugitive' },
-- File browser
{ 'nvim-neo-tree/neo-tree.nvim',
as = 'neo-tree',
branch = 'v2.x',
requires = {
'nvim-lua/plenary.nvim',
'kyazdani42/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
after = 'vimp',
cmd = { 'Neotree', 'NeoTree*' },
keys = { '<F2>', '<leader>gs', '<leader><S-TAB>' },
config = require 'psoxizsh.plugins.config.neotree'
},
-- Comment helpers
{ 'scrooloose/nerdcommenter' },
-- Stat line integrations
{ 'nvim-lualine/lualine.nvim',
requires = {
'kyazdani42/nvim-web-devicons',
'lewis6991/gitsigns.nvim'
},
config = require 'psoxizsh.plugins.config.lualine'
},
{ 'akinsho/bufferline.nvim',
as = "bufferline",
tag = "v1.*",
requires = { 'kyazdani42/nvim-web-devicons' },
after = 'vimp',
config = require 'psoxizsh.plugins.config.bufferline'
},
{ 'lewis6991/gitsigns.nvim',
tag = 'release',
requires = { 'nvim-lua/plenary.nvim' },
config = require 'psoxizsh.plugins.config.gitsigns'
},
-- Buffer mangement
{ 'qpkorr/vim-bufkill' },
{ 'romainl/vim-qf',
config = require 'psoxizsh.plugins.config.vim-qf'
},
-- IDE stuff + language highlighting
{ 'neoclide/coc.nvim',
disable = vim.fn.executable('node') ~= 1,
branch = 'release',
after = 'vimp',
config = require 'psoxizsh.plugins.config.coc'
},
{ 'neomake/neomake',
config = require 'psoxizsh.plugins.config.neomake'
},
{ 'vim-perl/vim-perl',
ft = 'perl',
run = 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny'
},
{ 'rust-lang/rust.vim',
ft = 'rust'
},
{ 'pearofducks/ansible-vim',
ft = {'yaml', 'yml'}
},
{ 'kevinoid/vim-jsonc' },
{ 'luochen1990/rainbow' },
{ 'sheerun/vim-polyglot' },
-- Fuzzy search helpers
{ 'junegunn/fzf',
cmd = 'FZF',
fn = { 'fzf#run', 'fzf#wrap' }
},
{ 'junegunn/fzf.vim',
config = require 'psoxizsh.plugins.config.fzf'
},
{ 'adelarsq/vim-matchit' },
{ 'mox-mox/vim-localsearch' },
-- Color themes
{ 'rakr/vim-one',
config = function() vim.cmd(string.format('colorscheme %s', vim.g.my_color_scheme or 'one')) end
},
{ 'romainl/vim-cool' },
-- Tmux integration for pane movement
{ 'christoomey/vim-tmux-navigator',
keys = { '<C-h>', '<C-j>', '<C-k>', '<C-l>' },
cmd = { 'TmuxNavigateLeft', 'TmuxNavigateDown', 'TmuxNavigateUp', 'TmuxNavigateRight', 'TmuxNavigatePrevious' },
config = require 'psoxizsh.plugins.config.vim-tmux-navigator'
},
-- Other
{ 'roxma/nvim-yarp' },
{ 'roxma/vim-hug-neovim-rpc' },
}
local function concatArray(a, b)
local result = {unpack(a)}
for i = 1,#b do
result[#a+i] = b[i]
end
return result
end
return function(extra)
extra = extra or {}
return concatArray(plugins, extra)
end

View File

@ -1,25 +0,0 @@
-- For configuration of NeoVim Treesitter
return {
{ 'nvim-treesitter/nvim-treesitter',
dependencies = { 'p00f/nvim-ts-rainbow', 'andymass/vim-matchup' },
opts = {
-- Trigger prompt to install plugin on loading relevant filetype
auto_install = true,
-- Added via p00f/nvim-ts-rainbow
rainbow = {
enable = true,
extended_mode = true,
},
-- Added via andymass/vim-matchup
matchup = {
enabled = true,
include_match_words = true,
disable_virtual_text = false,
},
},
keys = function() end, -- disable LazyVim keymaps (they're stupid)
},
}

View File

@ -1,100 +0,0 @@
-- NeoVim UI elements
--
-- These are constant features of your window, plus any pop-in elements, like
-- vim.notify, vim.ui, or virtual text handlers
local keys = require 'psoxizsh.key.binds'
local logo = string.rep('\n', 8) .. [[
]] .. '\n\n'
return {
-- Setting our logo for empty `nvim` loads
{ 'nvimdev/dashboard-nvim',
opts = function(_, opts)
opts.config = opts.config or {}
opts.config.header = vim.split(logo, '\n')
end
},
-- vim.notify handler
{ 'rcarriga/nvim-notify', version = '^3.0.0' },
-- Bottom line integrations
{ 'nvim-lualine/lualine.nvim',
dependencies = {
{ 'kyazdani42/nvim-web-devicons', version = false },
{ 'lewis6991/gitsigns.nvim' },
},
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/ui.lua#L96
opts = {
extensions = { 'fugitive', 'quickfix', 'man', 'fzf', 'neo-tree', 'toggleterm' }
},
},
-- Top line plugin
{ 'akinsho/bufferline.nvim',
version = '^4.0.0',
dependencies = { { 'kyazdani42/nvim-web-devicons', version = false } },
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/ui.lua#L39
opts = {
options = {
numbers = 'none',
diagnostics = false,
always_show_bufferline = true,
show_buffer_close_icons = false,
separator_style = 'slope',
sort_by = 'relative_directory',
},
},
keys = function()
return {
keys.Global.BufferNext:as { 'lazy', action = '<cmd>BufferLineCycleNext<CR>' },
keys.Global.BufferPrev:as { 'lazy', action = '<cmd>BufferLineCyclePrev<CR>' },
}
end
},
-- Git integration
{ 'lewis6991/gitsigns.nvim',
commit = 'd44a7948ffc717af578c424add818b7684c7ed68',
requires = { { 'nvim-lua/plenary.nvim', version = false } },
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/editor.lua#L247
opts = {
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol',
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
},
},
},
-- vim.ui.input & vim.ui.select handler
{ 'stevearc/dressing.nvim',
opts = {
input = {
default_prompt = '<|>',
mappings = { i = {
[keys.Plugin.Dressing.Close.Key] = 'Close',
[keys.Plugin.Dressing.Confirm.Key] = 'Confirm',
[keys.Plugin.Dressing.Prev.Key] = 'HistoryPrev',
[keys.Plugin.Dressing.Next.Key] = 'HistoryNext',
}},
},
select = { backend = { 'telescope', 'builtin' } },
},
},
}

View File

@ -1,133 +0,0 @@
---@class psoxizsh.startup
local M = {}
---Called first, before any user callbacks are triggered
function M.pre() end
---Called before any plugins are initialized, but after any early user callbacks
function M.early()
local o, g, fn, cmd = vim.opt, vim.g, vim.fn, vim.cmd
local au = require 'psoxizsh.autocmd'
-- local diagnostic = require 'psoxizsh.diagnostic'
g.autoformat = false
-- Color settings
o.background = 'dark'
o.termguicolors = true
-- Hide buffers don't close them
o.hidden = true
-- Sane pane opening
o.splitbelow = true
o.splitright = true
-- File indent opts
o.encoding = "utf-8"
o.shiftwidth = 2
o.tabstop = 8
o.softtabstop = 2
o.expandtab = true
o.list = true
o.listchars:append {
trail = '\u{02FD}',
extends = '\u{22B3}',
precedes = '\u{22B2}',
nbsp = '\u{02EC}',
conceal = '\u{2219}',
tab = '\u{2559}\u{254C}\u{2556}',
}
o.ignorecase = true
o.infercase = true
cmd 'filetype plugin indent on'
-- Lower update time (Default 4000)
o.updatetime = 300
-- Numbered lines
o.number = true
o.relativenumber = true
o.signcolumn = 'yes:1'
-- Disable '--INSERT--' and friends
o.showmode = false
-- Use existing buffers
o.switchbuf = { "useopen", "usetab" }
o.timeoutlen = 1000
-- Set global statusline (0.7+ only)
if fn.has('nvim-0.7') == 1 then o.laststatus = 3 end
-- Setup vim.diagnostic APIs
-- diagnostic.setup {}
au.PsoxFileAutos {
{ 'FileType', 'yaml', function() cmd 'setlocal indentkeys-=<:> ts=8 sts=2 sw=2 expandtab' end },
{ 'FileType', 'go', function() cmd 'setlocal ts=4 sts=4 sw=4 noexpandtab' end },
{ 'FileType', 'quickfix,netrw', 'setlocal nobuflisted' },
}
require('psoxizsh.startup.keybinds').register_keybinds()
end
---Called after plugins have finished initializing, but before any late user callbacks
function M.post()
local o, g, fn, cmd = vim.opt, vim.g, vim.fn, vim.cmd
local au = require 'psoxizsh.autocmd'
-- Setup file backups
cmd ':silent !mkdir -p ~/.vimbackup'
o.backupdir = fn.expand('~') .. '/.vimbackup'
o.directory = fn.expand('~') .. '/.vimbackup'
o.hlsearch = true
-- ripgrep settings
g.rg_highlight = 'true'
g.rg_derive_root = 'true'
-- Other
g.rainbow_active = 1
local color_highlights_override = function()
local hl = require 'psoxizsh.util.highlight'
-- For nvim-cmp, for whatever reason these are overwritten if set in the
-- config function
hl.CmpItemAbbrDeprecated { strikethrough = true }
hl.CmpItemAbbrMatch { bold = true }
hl.CmpItemAbbrMatchFuzzy { bold = true }
hl.CmpItemMenu { italic = true }
-- Disable stupid spelling highlights (the 90s were a weird time)
hl.SpellCap:clear()
hl.SpellLocal:clear()
hl.SpellRare:clear()
end
color_highlights_override()
au.PsoxColorSchemeOverrides {
{ 'ColorScheme', '*', color_highlights_override }
}
end
---Called after plugins have initialized and any user callbacks have triggered
function M.late()
-- Rest of config below is specifically not user override-able
local o = vim.opt
o.exrc = true
o.secure = true
o.modeline = true
o.modelines = 7
end
return M

View File

@ -1,80 +0,0 @@
---@class psoxizsh.startup.keybinds
local M = {}
---All non plugin specific, overridable keybinds registered by psoxizsh
function M.register_keybinds()
local map = LazyVim.safe_keymap_set
-- Better up/down
map({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true })
map({ 'n', 'x' }, '<Down>', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true })
map({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true })
map({ 'n', 'x' }, '<Up>', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true })
-- Move Lines
map('n', '<A-j>', '<cmd>m .+1<cr>==', { desc = 'Move Line Down' })
map('n', '<A-k>', '<cmd>m .-2<cr>==', { desc = 'Move Line Up' })
map('i', '<A-j>', '<esc><cmd>m .+1<cr>==gi', { desc = 'Move Line Down' })
map('i', '<A-k>', '<esc><cmd>m .-2<cr>==gi', { desc = 'Move Line Up' })
map('v', '<A-j>', ":m '>+1<cr>gv=gv", { desc = 'Move Line Down' })
map('v', '<A-k>', ":m '<-2<cr>gv=gv", { desc = 'Move Line Up' })
-- Clear search with <esc>
map({ 'i', 'n' }, '<esc>', '<cmd>noh<cr><esc>', { desc = 'Escape and Clear hlsearch' })
-- Ensure the 'n' always searches forward and 'N' always searches backwards,
-- regardless of search mode ('/' '?')
--
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
map('n', 'n', "'Nn'[v:searchforward].'zv'", { expr = true, desc = 'Next Search Result' })
map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next Search Result' })
map('o', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next Search Result' })
map('n', 'N', "'nN'[v:searchforward].'zv'", { expr = true, desc = 'Prev Search Result' })
map('x', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev Search Result' })
map('o', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev Search Result' })
-- Add undo break-points
map('i', ',', ',<c-g>u')
map('i', '.', '.<c-g>u')
map('i', ';', ';<c-g>u')
-- Better indenting
map('v', '<', '<gv')
map('v', '>', '>gv')
-- Diagnostics
map('n', ']o', vim.diagnostic.open_float, { desc = 'Line Diagnostics' })
map('n', ']g', M.diagnostic_goto(true), { desc = 'Next Diagnostic' })
map('n', '[g', M.diagnostic_goto(false), { desc = 'Prev Diagnostic' })
map('n', ']e', M.diagnostic_goto(true, 'ERROR'), { desc = 'Next Error' })
map('n', '[e', M.diagnostic_goto(false, 'ERROR'), { desc = 'Prev Error' })
-- Quit
map('n', '<leader>qa', '<cmd>qa<CR>', { desc = 'Quit All' })
-- Highlights under cursor
map('n', '<leader>hi', vim.show_pos, { desc = 'Inspect Pos' })
map('n', '<leader>hI', '<cmd>InspectTree<cr>', { desc = 'Inspect Tree' })
-- Windows
map('n', '<leader>w', '<C-w>', { desc = 'Windows', remap = true })
map('n', '<leader>wd', '<C-W>c', { desc = 'Delete Window', remap = true })
map('n', '<leader>-', '<C-W>s', { desc = 'New Window Below', remap = true })
map('n', '<leader>|', '<C-W>v', { desc = 'New Window Right', remap = true })
LazyVim.toggle.map('<leader>wz', LazyVim.toggle.maximize)
end
---Helper function for moving between diagnostics
---@param next boolean
---@param severity? 'ERROR'|'WARN'|'INFO'|'HINT'
---@return function
function M.diagnostic_goto(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
---@cast severity +integer
severity = severity and vim.diagnostic.severity[severity] or nil
return function() go({ severity = severity }) end
end
return M

View File

@ -0,0 +1,68 @@
local Util = {}
-- Reload a given module, returning the result of loading it.
function Util.mreload(module)
if package.loaded[module] then
package.loaded[module] = nil
end
return require(module)
end
-- Try reloading the given module, returning ok, module
function Util.try_mreload(module)
return pcall(Util.mreload, module)
end
-- Try reloading the given config module, returning either
-- its table or an empty one, if the module couldn't be loaded
--
-- The arguments can be:
-- 1. module string --> table
-- 2. module string --> fn() -> table
-- 3. table
-- 4. fn() --> table
--
-- It the latter cases, *configuration will not be reloaded*, this is
-- primaraily meant for inline, static configuration
function Util.try_mconfig(module)
if type(module) ~= "string" then
module = type(module) == "function" and module() or module
module = type(module) == "table" and module or {}
return module
end
local ok, config = Util.try_mreload(module)
config = type(config) == "function" and config() or config
return (ok and type(config) == "table") and config or {}
end
-- Retrieve the config table stored in the provided module,
-- merged with default the config module, if one is provided
--
-- The arguments can be:
-- 1. module string --> table
-- 2. module string --> fn() -> table
-- 3. table
-- 4. fn() --> table
--
-- It the latter cases, *configuration will not be reloaded*, this is
-- primaraily meant for inline, static configuration
--
-- Note: the config returned from the given module may optionally
-- set 'no_defaults = true' to opt out of the merging
function Util.mconfig(module, defaults)
module = Util.try_mconfig(module)
defaults = Util.try_mconfig(defaults)
if module.no_defaults then
return module
else
return vim.tbl_deep_extend('keep', module, defaults)
end
end
return Util

View File

@ -1,201 +0,0 @@
-- This module provides a highlight API that can be used in lua.
--
-- Each highlight may set its fg and bg colors, and any attributes
-- it may desire (italic, bold, etc).
--
-- You may also call .clear() on any highlight object to completely
-- remove the highlight
--
-- There are two major methods for using this module:
-- 1. By directly calling the module itself
-- 2. By indexing into the highlight group
--
-- Examples:
--
-- ```
-- local hl = require 'psoxizsh.util.highlight'
--
-- hl {
-- -- Note that colors are selected from sub objects first (gui.bg), then named top level
-- -- keys (ctermfg) and lastly unamed top level keys (fg, bg)
-- { 'Comment', italic = true, gui = { bg = '#0000' }, ctermbg = '#0000' },
-- -- You may select multiple highlight groups at once
-- { { 'TmuxSelect', 'TmuxHover' }, underdash = true, fg = '#FFFF', bg = '#FFFF' }
-- }
--
-- hl.clear({ 'Comment', 'TmuxHover', 'TmuxSelect' })
-- ```
--
-- ```
-- local hl = require 'psoxizsh.util.highlight'
--
-- hl.Comment { italic = true, underdot = true }
-- hl.LspInstallDone { bold = true, gui { bg = '#1E12' } }
-- hl.TmuxTree.clear()
-- ```
local cmd = vim.cmd
local ATTR = {
ITEMS = {
bold = 1, underline = 1, underlineline = 1,
undercurl = 1, underdot = 1, underdash = 1,
strikethrough = 1, reverse = 1, inverse = 1,
italic = 1, standout = 1, nocombine = 1,
NONE = 1,
},
KEYS = {
cterm = 1, ctermfg = 1, ctermbg = 1,
gui = 1, guifg = 1, guibg = 1, guisp = 1,
font = 1, blend = 1,
}
}
local Highlight = { mt = {} }
local Hl = { mt = {} }
-- Instantiates a new Hl object assiociated with the given hl_group
function Hl.new(hl_group)
local this = { group = hl_group, clear = Hl.clear }
setmetatable(this, Hl.mt)
return this
end
-- Deletes the highlight group assiociated with this Hl object
function Hl.clear(self)
cmd(string.format('highlight clear %s', self.group))
return true
end
-- Sets the highlight group assiociated with this Hl object
function Hl.set(self, n_opts)
local len, hl_line = 0, 'highlight ' .. self.group
for key, value in pairs(n_opts) do
len = len + 1
hl_line = hl_line .. Hl.attr2String(key, value)
end
if len == 0 then return nil end
cmd(hl_line)
return true
end
-- Normalizes the given highlight attributes into a format that can
-- be presented to ':highlight'
function Hl.normalize_attrs(_, raw)
local gui, cterm = raw.gui or {}, raw.cterm or {}
return {
cterm = Hl.attr_list('cterm', raw),
ctermfg = cterm.fg or raw.ctermfg,
ctermbg = cterm.bg or raw.ctermbg,
gui = Hl.attr_list('gui', raw),
guifg = gui.fg or raw.guifg or raw.fg,
guibg = gui.bg or raw.guibg or raw.bg,
font = gui.font or raw.font,
blend = gui.blend or raw.blend,
}
end
-- Generates a list of non nil attribute items, merging the
-- attrset and attrset[subkey] attributes trees, with the latter
-- having prefrence
function Hl.attr_list(subkey, attrset)
local list, sub = {}, attrset[subkey] or {}
for option, _ in pairs(ATTR.ITEMS) do
local resolved = sub[option] or attrset[option]
if resolved ~= nil then table.insert(list, option) end
end
return #list > 0 and list or nil
end
-- Formats the given attr key,value pair into a string that can be
-- given to ':highlight'
function Hl.attr2String(name, value)
if ATTR.KEYS[name] and #value > 0 then
local v = value
if type(v) == 'table' then
v = table.concat(value, ',')
end
return string.format(' %s=%s', name, v)
else
return ''
end
end
-- Sets the highlight group assiociated with this Hl object
function Hl.mt.__call(self, args)
local n_opts = Hl.normalize_attrs(self, args)
return Hl.set(self, n_opts)
end
-- Instantiates a new Highlight object
function Highlight.new()
local this = { clear = Highlight.clear }
setmetatable(this, Highlight.mt)
return this
end
-- Sets the given highlight group(s)
function Highlight.set(args)
local group = args[1] or args.group
if type(group) == 'table' then
local result = true
for _, g in ipairs(group) do
-- Failure is sticky, always record a failure if any group fails
if not Hl.new(g):set(args) and result then result = false end
end
return result
elseif type(group) == 'string' then
return Hl.new(group):set(args)
end
end
-- Clears the given highlight group.
--
-- Note this is closer to disabling the highlight group than it is to
-- resetting it to defaults
function Highlight.clear(group)
if type(group) == 'table' then
local result = true
for _, g in ipairs(group) do
-- Failure is sticky, always record a failure if any group fails
if not Hl.new(g):clear() and result then result = false end
end
return result
elseif type(group) == 'string' then
return Hl.new(group):clear()
end
end
-- Create a new Hl with the given name that can be called with a set
-- of highlight attrs to create / overwrite a highlight group
function Highlight.mt.__index(_, group)
return Hl.new(group)
end
-- Create highlight group(s), taking either a list or single attrset
function Highlight.mt.__call(_, args)
if args.group or type(args[1]) == 'string' then
return Highlight.set(args)
else
for _, attrset in ipairs(args) do
Highlight.set(attrset)
end
end
end
return Highlight.new()

View File

@ -1,49 +0,0 @@
local Util = { mt = {} }
local Lazy = { mt = {} }
local Submodules = {
mload = 'psoxizsh.util.mload',
}
function Util.new()
local this = { _submodules = Util.submodules() }
setmetatable(this, Util.mt)
return this
end
function Util.submodules()
local modules = {}
for key, mod in pairs(Submodules) do
modules[key] = Lazy.new(mod)
end
return modules
end
function Util.mt.__index(self, key)
for _, submod in pairs(self._submodules) do
if submod[key] then return submod[key] end
end
return nil
end
function Lazy.new(mod_name)
local this = { _module = false, _mod_name = mod_name }
setmetatable(this, Lazy.mt)
return this
end
function Lazy.mt.__index(self, key)
if not self._module then
self._module = require(self._mod_name)
end
return self._module[key]
end
return Util.new()

View File

@ -1,120 +0,0 @@
local M = {}
---@enum Code
local Code = { EXISTS = 1, NOT_FOUND = 0, LOAD_ERR = -1 }
--- Checks if the given module exists, and adds it to the preload
--- list if it does.
---@param module string
---@return boolean
local function module_exists(module)
if package.loaded[module] then return true end
for _, searcher in ipairs(package.loaders or package.searchers) do
local fn = searcher(module)
if type(fn) == 'function' then
package.preload[module] = fn
return true
end
end
return false
end
-- Reload a given module, returning the result of loading it.
function M.mreload(module)
if package.loaded[module] then
package.loaded[module] = nil
end
return require(module)
end
--- Try reloading the given module, returning (code, module|error)
--- Returns enumerated:
--- - Code.EXISTS, module
--- - Code.NOT_FOUND, nil
--- - Code.LOAD_ERR, error
---@param module string
---@return Code, any|string
function M.try_mreload(module)
if module_exists(module) then
local ok, result = pcall(M.mreload, module)
return ok and Code.EXISTS or Code.LOAD_ERR, result
else
return Code.NOT_FOUND, nil
end
end
-- Try reloading the given config module, returning either
-- its table or an empty one, if the module couldn't be loaded
--
-- The arguments can be:
-- 1. module string --> table
-- 2. module string --> fn() -> table
-- 3. table
-- 4. fn() --> table
--
-- It the latter cases, *configuration will not be reloaded*, this is
-- primarily meant for inline, static configuration
function M.try_mconfig(module)
-- Check if we were handed a object or function
-- instead of a module string
if type(module) ~= "string" then
module = type(module) == "function" and module() or module
module = type(module) == "table" and module or {}
return module
end
-- We definitely have a module string, try loading it
local c, config = M.try_mreload(module)
if c == Code.NOT_FOUND then
return {}
elseif c == Code.EXISTS then
return type(config) == "function" and config() or config
elseif c == Code.LOAD_ERR then
local options = {
title = string.format('Module Load Error: %s', module),
timeout = 2000
}
vim.notify_once(config, vim.log.levels.ERROR, options)
return {}
end
-- Catch fall through in case we ever add another Code variant
error(string.format("try_mconfig/1: unhandled Code '%s'", c))
end
-- Retrieve the config table stored in the provided module,
-- merged with default the config module, if one is provided
--
-- The arguments can be:
-- 1. module string --> table
-- 2. module string --> fn() -> table
-- 3. table
-- 4. fn() --> table
--
-- It the latter cases, *configuration will not be reloaded*, this is
-- primarily meant for inline, static configuration
--
-- Note: the config returned from the given module may optionally
-- set 'no_defaults = true' to opt out of the merging
function M.mconfig(module, defaults)
module = M.try_mconfig(module)
defaults = M.try_mconfig(defaults)
if module.no_defaults then
return module
else
return vim.tbl_deep_extend('keep', module, defaults)
end
end
return M

@ -1 +1 @@
Subproject commit c8e600f39779c6d2ef75b40304b5391a541c41df
Subproject commit 7dcabbe6826073ef6069c8a4b6f9a943f00d2df0

@ -1 +1 @@
Subproject commit 99469c4a9b1ccf77fade25842dc7bafbc8ce9946
Subproject commit b699a7e01c253ffb7818b02d62bce24190ec1019

View File

@ -8,6 +8,10 @@ if "test -f ~/.config/tmux/early.conf" {
source-file ~/.config/tmux/early.conf
}
if "test -f ~/.config/tmux/keys.conf" {
source-file ~/.config/tmux/keys.conf
}
set-option -g prefix C-a
set-option -g set-titles on
set-window-option -g automatic-rename on
@ -16,6 +20,7 @@ bind-key a send-prefix
set -g status-fg '#EEEEEE'
set -g status-bg '#333333'
set -g pane-border-status top
set -g pane-border-format '╢#[fg=#AA2277,italics]#{session_group}#[default] #[fg=#337755,bold,normal]#P/#D #[default,italics,fg=yellow]#{pane_tty}#[default]╟'
set -g display-panes-colour '#334400'
set -g mouse off
set -s escape-time 0
@ -23,18 +28,21 @@ set -g visual-activity on
set -g status-left-length 200
set -g status-right-length 200
set -g status-left '#{prefix_highlight} #[fg=blue,bold]#h #S:#I.#P (#D) #[default]'
set -g status-right '#T #[fg=yellow,bold]#(uptime -p)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default] '
set -g status-right '#T #[fg=yellow,bold]#( awk "{print \$1/86400,\"days\"}" /proc/uptime )#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default] '
set -g set-titles on
setw -g aggressive-resize on
setw -g monitor-activity on
# The following three makes italics work in tmux
set -g xterm-keys on
# Correctly set up terminal for truecolor support
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ',xterm-256color:Tc'
# Fix :h 'autoread' in Vim
set -g focus-events on
# set 24bit color for terminal that support it
set -as terminal-overrides ',xterm*:sitm=\E[3m'
set -as terminal-overrides ",xterm*:Tc"
set -as terminal-overrides ",alacritty*:Tc"
set -as terminal-overrides ",tmux-*:Tc"
# Refresh status line every 5 seconds
set -g status-interval 5
@ -47,8 +55,12 @@ bind-key e set-window-option synchronize-panes on
bind-key E set-window-option synchronize-panes off
bind m set -g mouse on \; display 'Mouse: ON'
bind M set -g mouse off \; display 'Mouse: OFF'
bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom
bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom
bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \
\; swap-pane -s tmux-zoom.0 \
\; select-window -t tmux-zoom
bind - last-window \
\; swap-pane -s tmux-zoom.0 \
\; kill-window -t tmux-zoom
# prefix + / to search
bind-key / copy-mode \; send-key ?
@ -59,3 +71,4 @@ if "test -f ~/.config/tmux/late.conf" {
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b "$TMUX_PLUGINS/tpm/tpm"

8
vimrc
View File

@ -215,7 +215,7 @@ if has_key(plugs, 'vim-qf')
let g:qf_auto_resize = 0
endif
endif
" ripgrep settings
let g:rg_highlight = 'true'
let g:rg_derive_root = 'true'
@ -230,7 +230,7 @@ let g:rainbow_active = 1
augroup PsoxFileAutos
autocmd!
autocmd FileType yaml setlocal indentkeys-=<:> ts=8 sts=2 sw=2 expandtab
autocmd FileType go setlocal ts=8 sts=4 sw=4 noexpandtab
autocmd FileType go setlocal ts=4 sts=4 sw=4 noexpandtab
\| autocmd BufWritePre <buffer> silent :call CocAction('format')
" Tidy nerdtree windiw
autocmd FileType nerdtree setlocal nocursorcolumn nonumber norelativenumber signcolumn=no
@ -419,9 +419,9 @@ nnoremap <silent> <leader>N :call ToggleGutter()<CR>
function! ToggleGutter() abort
if &number
exec "set nonumber norelativenumber signcolumn=no"
exec "set nonumber norelativenumber signcolumn=no nolist"
else
exec "set number relativenumber"
exec "set number relativenumber list"
try | set signcolumn=auto | catch | set signcolumn=yes:1 | endtry
endif
endfunction

@ -1 +1 @@
Subproject commit 46ae7ac8e35a52d2e2a8aed032d499cfcea49276
Subproject commit e82701cb2b8c42f63479bb1a34e4f78a7cb5b75c

@ -1 +1 @@
Subproject commit c3d4e576c9c86eac62884bd47c01f6faed043fc5
Subproject commit a411ef3e0992d4839f0732ebeb9823024afaaaa8

@ -1 +1 @@
Subproject commit 19ddc7f7cf0a4872d0dbfd8e4d9adc88eb37d1ff
Subproject commit acd4de5268ee23ffa3ec1f6f13a2ec91266e1564

@ -1 +1 @@
Subproject commit 87ce96b1862928d84b1afe7c173316614b30e301
Subproject commit 4abed97b6e67eb5590b39bcd59080aa23192f25d

@ -1 +1 @@
Subproject commit e0165eaa730dd0fa321a6a6de74f092fe87630b0
Subproject commit caa749d030d22168445c4cb97befd406d2828db0

@ -1 +0,0 @@
Subproject commit cd730cd347dcc0d8ce1697f67714a90f07da26ed

@ -1 +1 @@
Subproject commit 53d04fcdc1ab938fc8242755378e3647facd6bff
Subproject commit 3d3cff116a0c68ade27c537f85783afa80dd6e58

49
zshrc
View File

@ -31,7 +31,7 @@ path=( /bin /sbin /usr/bin /usr/sbin $path )
# Set funtion paths
foreach local p in ~/.local/share/zsh/functions ~/.config/zsh/functions $extra_fpath
[[ -d "$p" ]] && fpath=( "$p" $fpath )
[[ -d "$p" ]] && fpath=( "$p" $fpath )
end
[[ "$OS" != "Windows_NT" ]] && [[ -f /etc/profile ]] && source /etc/profile
@ -89,7 +89,7 @@ plugins=(
( which oc &>/dev/null ) && plugins+=( oc )
( which rsync &>/dev/null ) && plugins+=( rsync )
( which aws &>/dev/null ) && plugins+=( aws )
( which rust &>/dev/null ) && plugins+=( rust )
( which cargo &>/dev/null ) && plugins+=( rust )
( which jq &>/dev/null ) && plugins+=( jsontools )
( which encode64 &>/dev/null ) && plugins+=( encode64 )
( which docker-compose &>/dev/null ) && plugins+=( docker-compose )
@ -104,14 +104,18 @@ plugins=(
( which code &>/dev/null ) && plugins+=( vscode )
( which strfile &>/dev/null ) && plugins+=( chucknorris )
( which kubectl &>/dev/null ) && plugins+=( kubectl )
( which bazel &>/dev/null ) && plugins+=( bazel )
( which podman &>/dev/null ) && plugins+=( podman )
( which kubectx &>/dev/null ) && plugins+=( kubectx )
( which chroma &>/dev/null ) && plugins+=( colorize )
( which kate &>/dev/null ) && plugins+=( kate )
( which zoxide &>/dev/null ) && plugins+=( zoxide )
( [[ -e /etc/arch-release ]] ) && plugins+=( archlinux )
( [[ -e /etc/ubuntu-release ]] ) && plugins+=( ubuntu )
( [[ -e /etc/debian-release ]] ) && plugins+=( debian )
( [[ -e /etc/suse-release ]] ) && plugins+=( suse )
( [[ "$(uname)" == "Darwin" ]] ) && plugins+=( macos )
#( which vim &>/dev/null ) && plugins+=( vim-interaction )
( which vim &>/dev/null ) && plugins+=( vim-interaction )
( which ssh &>/dev/null ) && [[ -d ~/.ssh ]] && plugins+=( ssh-agent )
plugins+=(
plugins+=(
zsh-completions
zsh-autosuggestions
zsh-navigation-tools
@ -122,39 +126,28 @@ plugins+=(
if [[ "$OSTYPE" =~ "linux*" || "$OSTYPE" =~ "darwin*" || "$OSTYPE" == "cygwin" ]]
then
export VIMINIT='source $MYVIMRC'
export VIMHOME=~/.vim
# If neovim is installed, assume that we will not be supporting standard vim
if which nvim &>/dev/null
# Feature flag lua based Neovim config, until this is tested
# (and we figure out how to detect if we are running nvim or vim)
if [[ -n ${PSOXIZSH_EXPERIMENTAL_NEOVIM_LUA} ]]
then
[[ -d ~/.config/nvim/lua/config ]] || mkdir -p ~/.config/nvim/lua/config
[[ -d ~/.config/nvim/lua/plugins ]] || mkdir -p ~/.config/nvim/lua/plugins
[[ -e ~/.config/nvim/init.lua ]] || ln -s $PSOXIZSH/init.lua ~/.config/nvim/init.lua
[[ -e ~/.config/nvim/lua/plugins/init.lua ]] || echo 'return {}' > ~/.config/nvim/lua/plugins/init.lua
export MYVIMRC=$PSOXIZSH/init.lua
else
export VIMINIT='source $MYVIMRC'
export MYVIMRC=$PSOXIZSH/vimrc
cmp $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim 2>/dev/null || (
mkdir -vp $VIMHOME/autoload/
cp -av $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim
)
fi
if [[ -n ${PSOXIZSH_EXPERIMENTAL_NEOVIM_LUA} ]]
then
if [[ ! -e ~/.cache/.psoxizsh_did_warn_neovim_lua ]]
then
echo "$0:$LINENO: The environment variable 'PSOXIZSH_EXPERIMENTAL_NEOVIM_LUA' is now unused, and may be removed"
touch ~/.cache/.psoxizsh_did_warn_neovim_lua &>/dev/null
fi
fi
fi
if [[ -d ~/.ssh ]]
then
zstyle :omz:plugins:ssh-agent lifetime 36h
zstyle :omz:plugins:ssh-agent agent-forwarding on
if [[ -e ~/.ssh/autoload ]]
if [[ -e ~/.ssh/autoload ]]
then
zstyle :omz:plugins:ssh-agent identities $( cat ~/.ssh/autoload )
fi
@ -190,8 +183,12 @@ then
# and TPM will only expand one layer of source-file directives, so we
# symlink the base config to the user local config file, if it does not
# exist.
[ ! -f ~/.tmux.conf ] && ln -s $PSOXIZSH/tmux/tmux.conf ~/.tmux.conf
[ ! -f "$TMUX_PATH/plugins.conf" ] && ln -s "$PSOXIZSH/tmux/fragment/plugins.conf" "$TMUX_PATH/plugins.conf"
[[ ! -f $TMUX_PATH/tmux.conf ]] && cp -r "$PSOXIZSH/tmux/tmux.conf" "$TMUX_PATH/tmux.conf"
[[ ! -f ~/.tmux.conf ]] && ln -s $PSOXIZSH/tmux/tmux.conf ~/.tmux.conf
[[ ! -f "$TMUX_PATH/plugins.conf" ]] && ln -vs "$PSOXIZSH/tmux/fragment/plugins.conf" "$TMUX_PATH/plugins.conf"
[[ "$USER" == "astemmet" ]] && [[ ! -f $TMUX_PATH/keys.conf ]] && {
cp -v "$PSOXIZSH/tmux/fragment/ctrl-alt-movement.conf" "$TMUX_PATH/keys.conf"
}
export TMUX_PATH=$TMUX_PATH TMUX_PLUGINS="$TMUX_PATH/plugins" TMUX_CONFIG=~/.tmux.conf
fi
@ -209,7 +206,9 @@ alias curlj="curl -H 'Content-Type: application/json' "
which nvim >/dev/null 2>&1 && alias vim="$(which nvim)"
alias v=vim
[[ -x /usr/bin/yay ]] && [[ "$(whoami)" != "pacman" ]] && alias yay='sudo -iupacman /usr/bin/yay'
[[ -x /usr/bin/paru ]] && [[ "$(whoami)" != "pacman" ]] && alias yay='sudo -iupacman /usr/bin/paru'
[[ -x /usr/bin/paru ]] && [[ "$(whoami)" != "pacman" ]] && alias paru='sudo -iupacman /usr/bin/paru'
[[ -x /usr/bin/bat ]] && export MANPAGER="sh -c 'col -bx | bat -l man -p'"
typeset -A key