Compare commits

...

41 Commits

Author SHA1 Message Date
e02cdd0b66 Attempt to automatically extract session name from curren screen session 2024-06-06 20:56:25 -04:00
c2ebab9a41 Don't do weird things with autocmd 2024-06-06 20:56:08 -04:00
5426e96bed Merge branch 'master' of git.nixy.moe:nixy/dotfiles 2024-06-05 21:03:06 -04:00
51b8138cf3 Update regex to match new direnv versions 2024-06-03 16:31:27 -04:00
790c132e07 Merge branch 'master' of https://git.nixy.moe/nixy/dotfiles 2024-06-03 16:30:07 -04:00
008d3720ff Add basic autocmds to wrap on markdown and open logs at the end 2024-06-02 17:24:00 -04:00
85cee95c2e Make a root single user nix install possible
Taken from this issue https://github.com/NixOS/nix/issues/1559

This is only so that the script will succeed when running in docker
containers without systemd (can't use multi-user) and that have root as
the default user, a shockingly common practice
2024-05-22 14:25:21 +00:00
7360e32a08 Automatically install coder in nix environments 2024-05-21 20:33:17 +00:00
c2286bb299 Remove vestigial vagrant reference 2024-05-21 20:33:17 +00:00
4c48565a8f Add installers for common programs to bring along 2024-05-21 20:33:17 +00:00
edd3b72430 Make direnv prompt updating conditional to direnv's presence 2024-05-21 20:33:17 +00:00
772da66b96 Fix Direnv prompt whenver off primary hosts 2024-05-21 20:33:17 +00:00
ac168d66d7 Beginner luasnip configuration for terraform 2024-05-21 20:33:17 +00:00
8937b9f566 Option select on tput working or use old fallback control codes 2024-05-21 20:33:17 +00:00
c73a495540 Attempt to fix recursive cloning for submodules 2024-05-21 20:31:27 +00:00
406c50b4a5 Add a vim option select 2024-05-21 20:31:27 +00:00
4360067486 Merge branch 'master' of https://git.nixy.moe/nixy/dotfiles 2024-05-13 13:55:38 -04:00
b156901695 Added conditional coloring of bash prompt dependent on direnv status 2024-05-12 22:58:50 -04:00
bc00f7a310 Option select on tput working or use old fallback control codes 2024-04-15 16:43:28 +00:00
16545b322f Attempt to fix recursive cloning for submodules 2024-04-15 16:18:09 +00:00
dafc207f96 Add a vim option select 2024-04-15 14:38:06 +00:00
f81ee2834a Move persistent history to more appropriate location 2024-04-10 22:38:26 -04:00
b7ce819dba Update git plugins 2024-04-10 22:35:31 -04:00
f7b5147450 Improve bash history, add persistent history file 2024-04-10 16:47:36 +00:00
6246e75d81 Alias cat to always add a newline
Sometimes if a file doesn't have a newline cat will not do one, causing
prompt strangeness
2024-04-10 16:46:42 +00:00
d901efe31a Add aliases for easy searching of history 2024-04-10 16:46:31 +00:00
e15f254143 Add readline shortcuts for improved history searching 2024-04-10 16:37:56 +00:00
fa7af5ee1f Address issues that cause shell lines to break 2024-02-27 17:14:13 +00:00
819c41de45 Beginning binding/config for luasnip 2024-02-15 20:13:36 -05:00
c97ef61d30 Split up neonvim configuration into lua files rather than lua heredoc 2024-02-15 20:13:01 -05:00
0d5d35d5e1 Pin plugins to specific tagged versions rather than master + add luasnip 2024-02-15 18:42:52 -05:00
8c379c558a Update plugins 2024-02-15 18:17:27 -05:00
8ce45fc87c Update lspconfig 2024-02-09 17:24:02 +00:00
ed9e0d4419 Add conditional SSH config construction 2024-02-08 14:55:12 +00:00
dd35fe3b20 Update plugins 2024-02-06 20:08:30 -05:00
c26f6a6bf5 More neovim testing 2024-02-06 18:29:51 -05:00
08713c254f Begin to examine neovim config 2024-01-31 01:36:32 +00:00
2d14e91f81 Add support for progressive neovimming 2024-01-30 14:48:07 +00:00
8dda8c7fbc Set hostname in prompt if through SSH 2024-01-04 15:23:08 +00:00
7d67ff0662 Add firefox as BROWSER 2023-12-03 21:53:24 -05:00
Andrew R. M
a2076fd6f1 Make dotfiles compatible with gitpod style dotfiles
Add an install.sh that attempts to determine the OS, install stow and
then call my apply-dotfiles script to use stow.

The old installation process that was based on nix, has been moved to
nix-install.
2023-10-09 16:52:29 +00:00
39 changed files with 625 additions and 53 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
taskwarrior/.task/*.data
ssh/.ssh/extra.conf

15
.gitmodules vendored
View File

@@ -40,3 +40,18 @@
[submodule "vim/.vim/bundle/ale"]
path = vim/.vim/bundle/ale
url = https://github.com/dense-analysis/ale
[submodule "vim/.vim/nvim-bundle/plenary"]
path = vim/.vim/nvim-bundle/plenary
url = https://github.com/nvim-lua/plenary.nvim.git
[submodule "vim/.vim/nvim-bundle/telescope"]
path = vim/.vim/nvim-bundle/telescope
url = https://github.com/nvim-telescope/telescope.nvim.git
[submodule "vim/.vim/nvim-bundle/nvim-lspconfig"]
path = vim/.vim/nvim-bundle/nvim-lspconfig
url = https://github.com/neovim/nvim-lspconfig.git
[submodule "vim/.vim/nvim-bundle/indent-blankline"]
path = vim/.vim/nvim-bundle/indent-blankline
url = https://github.com/lukas-reineke/indent-blankline.nvim.git
[submodule "vim/.vim/nvim-bundle/LuaSnip"]
path = vim/.vim/nvim-bundle/LuaSnip
url = https://github.com/L3MON4D3/LuaSnip.git

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
# Dotfiles
This is my personal dotfiles repository containing all my configurations (and some credentials in git-crypt). Most of these files are managed using [GNU Stow](https://www.gnu.org/software/stow/) to symlink them into place while the real files live in this repository under version control.
## Installation
To place all the configuration files in their ultimate location we use the `apply-dotfiles` bash script. This script requires both `git` and `stow` to be available so we wrap this in either `install.sh` to install it similar to [gitpod dotfiles](https://www.gitpod.io/docs/configure/user-settings/dotfiles#custom-installation-script) (which are also used for [coder](https://coder.com/) workspaces) or `nix-install` for my many machines that have either Nix or NixOS installed.
## Secret Management
I use `git-crypt` to keep some sensitive files in this repo. Namely my taskwarrior configuration which uses locally stored certificates in it's configuration as a means of authentication. While using `git-crypt` for this is pretty functional the process of moving PGP keys around is onerous enough that I haven't put a lot of effort into automating this portion of my dotfiles. It's there, there are scripts to interact with it but it's still mostly manual right now
### Things to watch out for
As anyone who maintains their own dotfiles long enough will know, your mileage will vary depending on your target OS. You have static configuration files setup against one version of software being moved to other machines that might use older/newer versions where configuration options have changed. You might end up getting annoying warnings (common in vim) or things just might not work at all. You may have to tune things for the lowest common denominator or create alternate configurations for specific operating system.

View File

@@ -1,13 +1,35 @@
#!/usr/bin/env nix-shell
#! nix-shell -p stow -i bash
#!/usr/bin/env bash
stow bash
stow sh
stow readline
apply_dotfile() {
directory_to_stow="${1}"
stow --adopt -S -t "${HOME}" "${directory_to_stow}"
}
stow vim
# Adopt will change the files in stow to match existing files.
# We don't want this, we just want to handle existing files gracefully.
# We simply adopt all the files and then at the end restore our git repo to undo changes
restore_from_adoption() {
git restore .
}
stow ruby
stow python
apply_dotfile bash
apply_dotfile sh
apply_dotfile readline
stow ssh
apply_dotfile vim
apply_dotfile ruby
apply_dotfile python
# Check that SSH version is above 9.2 (where EnableEscapeCommandline was added) before conditionally adding
# a config file. This is then included in the main config
SSH_VERSION=$(ssh -V 2>&1 | cut -d',' -f 1 | cut -d '_' -f 2)
if [[ "${SSH_VERSION}" =~ ^9\.[1-9]{0,1}[2-9].*$ ]]; then
cat <<CONFIG > ssh/.ssh/extra.conf
EnableEscapeCommandline yes
CONFIG
fi
apply_dotfile ssh
restore_from_adoption

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env nix-shell
#! nix-shell -p stow envsubst -i bash
#!/usr/bin/env bash
envsubst -i taskwarrior/.taskrc.envsubst.template -o taskwarrior/.taskrc
stow taskwarrior

View File

@@ -37,6 +37,14 @@ alias df="df -h"
# Human readable file size inspection
alias du="du -sh"
# History searches
alias phistory='cat ${PERSISTENT_HISTFILE}'
alias hgrep='history | grep --color'
alias phgrep="cat ${PERSISTENT_HISTFILE} | grep --color"
alias hfzf='history | fzf'
alias phfzf="cat ${PERSISTENT_HISTFILE} | fzf"
#{- NETWORKING -}#
@@ -46,6 +54,8 @@ alias ping="ping -c 4"
# Show progress while syncing
alias rsync="rsync --progress"
# Force a newline at the end of curl responses to prevent artifacting
alias curl="curl -w '\n'"
#{- SHELL INTROSPECTION -}#

View File

@@ -24,7 +24,7 @@ export HISTSIZE=-1
#{- SHELL OPTIONS -}#
# Append history to $HISTFILE when bash exits, instead of overwriting it
shopt -s histappend
#shopt -s histappend
# Attempt to preserve multi-line commands in history with embedded newlines
shopt -s cmdhist lithist

View File

@@ -2,18 +2,43 @@
#{- PROMPT -}#
red="\[\033[1;31m\]"
green="\[\033[1;32m\]"
yellow="\[\033[1;33m\]"
blue="\[\033[1;34m\]"
magenta="\[\033[1;35m\]"
cyan="\[\033[1;36m\]"
no_color="\[\033[0m\]"
if which tput &> /dev/null && tput bold &> /dev/null; then
red="\001$(tput bold)$(tput setaf 1)\002"
green="\001$(tput bold)$(tput setaf 2)\002"
yellow="\001$(tput bold)$(tput setaf 3)\002"
blue="\001$(tput bold)$(tput setaf 4)\002"
magenta="\001$(tput bold)$(tput setaf 5)\002"
cyan="\001$(tput bold)$(tput setaf 6)\002"
no_color="\001$(tput sgr0)\002"
else
red="\[\033[1;31m\]"
green="\[\033[1;32m\]"
yellow="\[\033[1;33m\]"
blue="\[\033[1;34m\]"
magenta="\[\033[1;35m\]"
cyan="\[\033[1;36m\]"
no_color="\[\033[0m\]"
fi
export PS1="${green}\$${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ]; then
export DIRENV_PS1="${red}\$${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
fi
export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then
update_prompt() {
if direnv status | grep -iEq 'RC allowed (true|0)'; then
PS1=${DIRENV_PS1}
else
PS1=${ORIG_PS1}
fi
}
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
fi
# Continuation Prompt: "> " in cyan
export PS2="${cyan}>${no_color} "
@@ -22,12 +47,31 @@ export PS4="${blue}#${no_color} "
#{- HISTORY -}#
#shopt -s histappend
#export PROMPT_COMMAND="history -a; histroy -c; history -r; $PROMPT_COMMAND"
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
# PROMPT_COMMAND="echo hist1; history; history -n; echo hist2; history; history -w; echo hist3; history; history -c; echo hist4; history; history -r; echo hist5; history; $PROMPT_COMMAND"
export HISTFILE="$HOME/.history/bash"
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL="erasedups:ignoreboth"
export HISTFILESIZE=-1
export HISTSIZE=-1
export HISTCONTROL="ignoreboth:erasedups"
shopt -s histappend
export PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
export PERSISTENT_HISTFILE="${HOME}/.history/bash_persistent_history"
log_bash_persistent_history()
{
local rc=$?
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}"
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
PROMPT_COMMAND="log_bash_persistent_history; $PROMPT_COMMAND"
#{- SOURCING -}#

View File

@@ -15,3 +15,19 @@ maths()
{
bc -l <<< "scale=2; $*"
}
cat_with_newline()
{
cat "$@" && echo
}
alias cat="cat_with_newline"
vim_option_select()
{
if which nvim &> /dev/null; then
nvim "$@"
else
vim "$@"
fi
}
alias vim="vim_option_select "

45
install.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# Install my dotfiles on a variety of systems
set -ex
echo "PWD: $PWD"
# Coder dotfiles (and most other ways of doing this) will not do a recursive clone, so do that in install script.
git submodule init && git submodule update
# Match case insensitively to make things easier for this part
shopt -s nocasematch
echo "Installing dotfiles..."
if [ -f /etc/os-release ]; then
echo "Idenitfying OS to install GNU stow..."
if [ "${CODER_OS_FAMILY:-}" == "Ubuntu" ] || grep -q -i debian /etc/os-release; then
echo "Detected OS as Ubuntu, using apt";
sudo apt-get update;
sudo apt-get install -y stow;
installers/install-nix.sh
elif grep -q -i rhel /etc/os-release || grep -q -i fedora /etc/os-release; then
echo "You've got RedHat (or maybe Fedora)! Which is unsupported right now sorry!";
# sudo yum install -y stow;
# sudo yum clean all;
exit 1
elif grep -q -i alpine /etc/os-release; then
echo "You've got Alpine! Which is unsupported right now sorry!";
exit 1;
# apk add --no-cache jq curl;
else
echo "ERROR: Unable to identify OS!" 1>&2;
exit 1;
fi;
else
if [ "${CODER_TEMPLATE_TYPE}" == "Devcontainer" ]; then
installers/install-nix.sh
fi
echo "ERROR: Unable to find '/etc/os-release' information!" 1>&2;
exit 1;
fi
shopt -u nocasematch
# Apply the dotfiles with stow
echo "Running apply dotfiles"
./apply-dotfiles
echo "Dotfiles applied successfully"

View File

@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Installs packages to the nix profile using nix profile
# Reference: https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management
set -ex
nix_packages=(
# Personal tools
"vimHugeX"
"ranger"
"jq"
"yq"
# Neovim + Plugin dependencies
"neovim"
"ripgrep"
"fzf"
# Language servers
"helm-ls"
"yaml-language-server"
"lua-language-server"
# ProgrammingLanguages
"lua52Packages.lua"
"pass"
"gnupg"
# Professional tools
"skopeo"
"awscli2"
"kubectl"
"kubernetes-helm"
"rancher"
#"terraform"
"opentofu"
"terragrunt"
)
unstable_packages=(
# CVE in NixOS stable version of vault
"vault"
)
mkdir -p ~/.config/nixpkgs/
templated_insert=$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; done)
# Reference: https://discourse.nixos.org/t/nix-profile-in-combination-with-declarative-package-management/21228/9
cat << EOF > ~/.config/nixpkgs/flake.nix
{
description = "A declarative system installation";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; # also possible: nixos-unstable
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in {
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.\${system};
in {
default = self.packages.\${system}.myPackageCollection;
myPackageCollection = # libs and clis
let
pkgs = nixpkgs.legacyPackages.\${system}; # here we need just legacy packages
in pkgs.buildEnv {
name = "myPackages";
paths = with pkgs; [
${templated_insert}
];
extraOutputsToInstall = [ "man" "doc" ];
};
}); # packages
}; # outputs
}
EOF
install_nix_packages()
{
# The name of the package we are going to install, needed to check for presence/uninstall
package_name=packages.x86_64-linux.myPackageCollection
if [ "${nix_packages[*]}" ]; then
if nix profile list | cut -d' ' -f 2 | grep -q "${package_name}"; then
echo "Removing previous version of profile"
nix profile remove "${package_name}"
fi
echo "Installing profile"
nix profile install "${HOME}/.config/nixpkgs/flake.nix#myPackageCollection"
fi
}
install_nix_packages

41
installers/install-nix.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Install the Nix package manager as a secondary package manager.
# This can sometimes be useful for getting more recent packages.
set -e
set -x
# Abort installation if Nix is already installed
if [ -d /nix ]; then
exit 0
fi
# Workaround to make a single user install work as root
if [ "${USER:-}" == "root" ] || [ "${UID:-}" == "0" ]; then
mkdir -p /etc/nix
echo "build-users-group =" > /etc/nix/nix.conf
fi
# Download the Nix installer and it's signature from NixOS.org
curl -so install-nix https://releases.nixos.org/nix/nix-2.18.1/install
# Run the installer
sh ./install-nix
# Source the nix profile
cat << EOF > ~/.bashrc
# Source nix if it's installed
if [ -r ~/.nix-profile/etc/profile.d/nix.sh ]; then
. ~/.nix-profile/etc/profile.d/nix.sh
fi
EOF
# Remove the installer and signature
rm -f ./install-nix
# Enable flakes and the nix command
mkdir -p ~/.config/nix
cat <<EOF > ~/.config/nix/nix.conf
experimental-features = flakes nix-command
EOF

7
nix-install Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env nix-shell
#! nix-shell -p stow envsubst -i bash
# Uses nix shell to setup the dotfiles
./apply-dotfiles
# Secret dotfiles need interactivity anyways, not worrying about this for now
# ./apply-secret-dotfiles

View File

@@ -74,3 +74,10 @@ set keymap vi-insert
Control-q: quoted-insert
Control-@: set-mark
Control-_: undo
"\e[A": history-search-backward
"\e[B": history-search-forward
set keymap vi-command
j: history-search-forward
k: history-search-backward
"\e[A": history-search-backward
"\e[B": history-search-forward

View File

@@ -22,6 +22,9 @@ export LC_COLLATE="C"
export EDITOR="vim"
export VISUAL="vim"
# Export browser preferences.
export BROWSER="firefox"
# Export pager preferences.
export PAGER="less"
export LESSHISTFILE="-"

View File

@@ -1 +1 @@
EnableEscapeCommandline yes
Include ~/.ssh/extra.conf

24
vim/.config/nvim/init.vim Normal file
View File

@@ -0,0 +1,24 @@
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
lua <<EOF
vim.g.mapleader = ','
require('user.lspconfig')
require('user.indentblanklines')
require('user.luasnip')
EOF
nnoremap <leader>ib <cmd>IBLToggle<cr>
" Beginner keybinds for telescope
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" lua print('this also works')
command! LuaRuntimePath lua print(vim.inspect(vim.api.nvim_list_runtime_paths()))

View File

@@ -0,0 +1,8 @@
-- Configure the 'indent-blankline' plugin
-- Look at configuring this for rainbow blocks at some point
require('ibl').setup{
enabled = false,
indent = {
char = '|'
}
}

View File

@@ -0,0 +1,85 @@
print('User LSP Configuration loaded')
local lsp = require('lspconfig')
-- Configure LuaLS for lua
lsp.lua_ls.setup{
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
}
}
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end
}
lsp.pylsp.setup{}
lsp.solargraph.setup{}
-- Setup LSP bindings
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function()
local bufmap = function(mode, lhs, rhs)
local opts = {buffer = true}
vim.keymap.set(mode, lhs, rhs, opts)
end
-- Displays hover information about the symbol under the cursor
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
-- Jump to the definition
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
-- Jump to declaration
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
-- Lists all the implementations for the symbol under the cursor
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
-- Jumps to the definition of the type symbol
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
-- Lists all the references
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
-- Displays a function's signature information
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
-- Renames all references to the symbol under the cursor
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
-- Selects a code action available at the current cursor position
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
-- Show diagnostics in a floating window
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
-- Move to the previous diagnostic
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
-- Move to the next diagnostic
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
end
})

View File

@@ -0,0 +1,98 @@
local ls = require("luasnip")
local fmt = require('luasnip.extras.fmt')
local rep = require('luasnip.extras').rep
-- some shorthands...
-- Taken from video/guide. Honestly I don't like these should probably work on learning their names
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local l = require("luasnip.extras").lambda
local rep = require("luasnip.extras").rep
local p = require("luasnip.extras").partial
local m = require("luasnip.extras").match
local n = require("luasnip.extras").nonempty
local dl = require("luasnip.extras").dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local types = require("luasnip.util.types")
local conds = require("luasnip.extras.conditions")
local conds_expand = require("luasnip.extras.conditions.expand")
ls.config.set_config {
history = true,
-- This allows dynamic snippets to update as you type
updateevents = "TextChanged,TextChangedI"
}
-- Expand if expandable, or jump forward if jumpable
-- If neither, do nothing queitly
-- vim.keymap.set({ "i", "s" }, "<C-K>", function()
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, { silent = true })
-- end, { silent = true })
-- Jump backwards to the previous jumpable point
-- vim.keymap.set({ "i", "s" }, "<C-J>", function()
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if ls.jumpable(-1) then
ls.jump(-1)
end
end, { silent = true })
-- Selecting from a list of options in a choice node
-- vim.keymap.set({ "i" }, "<C-L>", function()
vim.keymap.set({ "i" }, "<A-Tab>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end)
-- Allow us to hot reload snippets by unloading snippets then resourcing file
local ls_cleanup = function()
ls.cleanup()
vim.cmd("source ~/.config/nvim/lua/user/luasnip.lua")
end
vim.keymap.set("n", "<leader><leader>s", ls_cleanup)
ls.add_snippets(nil, {
terraform = {
ls.parser.parse_snippet("res", "resource \"$1\" \"$2\" {\n $3\n}"),
ls.parser.parse_snippet("dat", "data \"$1\" \"$2\" {\n $3\n}"),
ls.parser.parse_snippet("var", "variable \"$1\" {\n type = $2\n description = $3\n}"),
ls.parser.parse_snippet("loc", "locals {\n $1\n}"),
ls.parser.parse_snippet("mod", "module {\n source = $1\n}"),
},
lua = {
ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend"),
ls.parser.parse_snippet("mf", "$1.$2 = function($3)\n $0\nend"),
-- Example from snippet writing guide: https://github.com/L3MON4D3/LuaSnip/blob/master/Examples/snippets.lua#L190
s(
"fmt1",
fmt("To {title} {} {}.", {
i(2, "Name"),
i(3, "Surname"),
title = c(1, { t("Mr."), t("Ms.") }),
})
),
-- Example from video: https://www.youtube.com/watch?v=Dn800rlPIho
s(
"req",
fmt("local {} = require('{}')", {
i(1, "default"),
rep(1)
})
),
}
})

View File

@@ -53,7 +53,7 @@ exe "let s:bg_white = ' ctermbg=".s:white"'"
exe "let s:fg_none = ' ctermfg=NONE'"
exe "let s:fg_default = ' ctermfg=".s:foreground"'"
exe "let s:fg_black = ' ctermfg=".s:black"'"
exe "let s:fg_red = ' ctermfg=".s:red"'"
exe "let s:fg_red = ' ctermfg=".s:bright_red"'"
exe "let s:fg_green = ' ctermfg=".s:green"'"
exe "let s:fg_yellow = ' ctermfg=".s:yellow"'"
exe "let s:fg_blue = ' ctermfg=".s:blue"'"
@@ -135,20 +135,20 @@ exe "hi! Todo" .s:fmt_bold .s:fg_magenta.s:bg_none
" *Todo anything that needs extra attention; mostly the
" keywords TODO FIXME and XXX
exe "hi! StatusLine" .s:fg_dark_grey .s:bg_bright_red
exe "hi! StatusLineNC" .s:fg_dark_grey .s:bg_bright_magenta
exe "hi! StatusLine" .s:fg_blue .s:bg_none
exe "hi! StatusLineNC" .s:fg_blue .s:bg_none
exe "hi! LineNr" .s:fg_dark_grey .s:bg_none
exe "hi! CursorLineNr" .s:fg_bright_magenta .s:bg_none
exe "hi! TabLine" .s:fmt_none .s:fg_bright_red .s:bg_dark_grey
exe "hi! TabLineSel" .s:fmt_none .s:fg_bright_magenta .s:bg_dark_grey
exe "hi! TabLineFill" .s:fmt_none .s:fg_none .s:bg_dark_grey
exe "hi! TabLine" .s:fmt_none .s:fg_black .s:bg_blue
exe "hi! TabLineSel" .s:fmt_bold .s:fg_black .s:bg_cyan
exe "hi! TabLineFill" .s:fmt_none .s:fg_none .s:bg_bright_blue
exe "hi! CursorLine" .s:fmt_none .s:bg_dark_grey
exe "hi! CursorColumn" .s:fmt_none .s:bg_dark_grey
exe "hi! CursorLine" .s:fmt_none .s:bg_blue
exe "hi! CursorColumn" .s:fmt_none .s:bg_blue
exe "hi! VertSplit" .s:fg_dark_grey .s:bg_dark_grey
exe "hi! VertSplit" .s:fg_blue .s:bg_blue
"if &background == "light"
" highlight Normal ctermfg=0 ctermbg=15

View File

@@ -6,7 +6,7 @@ set nocompatible
"{- PLUGIN MANAGER -}"
" Load pathogen, the plugin manager, which then loads all plugins "
runtime bundle/pathogen/autoload/pathogen.vim
execute pathogen#infect()
execute pathogen#infect('bundle/{}', 'nvim-bundle/{}')
"{- COMMANDS -}"
@@ -31,7 +31,7 @@ set nocompatible
"{- INTERFACE -}"
" Colors and syntax highlighting "
colorscheme dim
colorscheme halfdab
set background=dark
filetype plugin on
syntax on
@@ -103,7 +103,8 @@ set nocompatible
set complete+=kspell
" Match the longest completion option then display menu
set completeopt=menuone,longest
"set completeopt=menuone,longest
set completeopt=menu,menuone,noselect
" Use UTF-8 "
set encoding=utf-8
@@ -118,7 +119,11 @@ set nocompatible
set spelllang=en_us,cjk
" Store the viminfo file in the .vim directory "
set viminfo+=n$HOME/.vim/.viminfo
if !has('nvim')
set viminfo+=n$HOME/.vim/.viminfo
else
set viminfo+=n$HOME/.vim/.shada
endif
" Don't use a pager "
set nomore
@@ -128,6 +133,19 @@ set nocompatible
set clipboard=unnamed,unnamedplus
endif
"{- AUTOCOMMANDS -}"
" Wrap lines for markdown files by default
augroup mdwrap
autocmd BufReadPost *.md :set wrap
augroup END
" Automatically go to the last line for log files
augroup logend
autocmd BufReadPost *.log normal G
autocmd BufReadPost *.logs normal G
augroup END
"{- PLUGINS -}"
"{- SLIME -}"
@@ -138,7 +156,8 @@ set nocompatible
let g:slime_paste_file = tempname()
" Default session for screen
let g:slime_default_config = {"sessionname": "REPL", "windowname": ""}
let sessionname = v:version >= 801 ? trim(system("echo $STY | cut -d. -f2")) : "default"
let g:slime_default_config = {"sessionname": sessionname, "windowname": ""}
"{- SUPERTAB -}"
" Use the default vim completion keys for supertab completion
@@ -190,4 +209,3 @@ set nocompatible
\ 'type' : 't'
\ }
\ }