diff --git a/bash/bashrc.sh b/bash/bashrc.sh new file mode 100644 index 0000000..56bc5c3 --- /dev/null +++ b/bash/bashrc.sh @@ -0,0 +1,170 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi +# Allow the user to set the title. +function title { + PROMPT_COMMAND="echo -ne \"\033]0;$1 (on $HOSTNAME)\007\"" +} +export BR2_DL_DIR="$HOME/.buildroot-dl/" +export PATH="${HOME}/tools/:$PATH" +alias python=python3 +alias vi="reload_display && nvim" +alias start="dtach -c /tmp/lvimsession ~/tools/lvim" +alias resume="dtach -a /tmp/lvimsession" +export EDITOR='nvim' +alias tmux="tmux" + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +if [ -d "$HOME/.cargo" ]; then + . "$HOME/.cargo/env" +fi +export TERM="xterm-256color" +date="$(date +%m)" +if [ "$date" -gt "11" ]; then + # December + export PS1="\[$(tput setaf 39)\]\u\[$(tput setaf 45)\]@\[$(tput setaf 51)\]\h \[$(tput setaf 195)\]\w \[$(tput sgr0)\]$ " +elif [ "$date" -gt "08" ]; then + # September/October/November + export PS1="\[$(tput setaf 216)\]\u\[$(tput setaf 160)\]@\[$(tput setaf 202)\]\h \[$(tput setaf 131)\]\w \[$(tput sgr0)\]$ " +elif [ "$date" -gt "05" ]; then + # June/July/August + export PS1="\[$(tput setaf 47)\]\u\[$(tput setaf 156)\]@\[$(tput setaf 227)\]\h \[$(tput setaf 231)\]\w \[$(tput sgr0)\]$ " +elif [ "$date" -gt "02" ]; then + # March/April/May + export PS1="\[$(tput setaf 34)\]\u\[$(tput setaf 40)\]@\[$(tput setaf 46)\]\h \[$(tput setaf 154)\]\w \[$(tput sgr0)\]$ " +else + # January/Feburary + export PS1="\[$(tput setaf 39)\]\u\[$(tput setaf 45)\]@\[$(tput setaf 51)\]\h \[$(tput setaf 195)\]\w \[$(tput sgr0)\]$ " +fi +if [ "$date" -eq "05" ] && [ "$(date +%d)" -eq "22" ]; then + # Crazy birthday prompt + export PS1="\[$(tput setaf 196)\]\u\[$(tput setaf 14)\]@\[$(tput setaf 10)\]\h \[$(tput setaf 11)\]\w \[$(tput sgr0)\]$ " +fi + + +export PROMPT_DIRTRIM=3 +export PATH="$HOME/.local/bin:$PATH" + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash + +export PROMPT_COMMAND="history -a; history -n" + +alias vimdiff="nvim -d" +alias reload_display="export DISPLAY=\"\`tmux show-env | sed -n 's/^DISPLAY=//p'\`\"" +alias gitlog="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all" +alias resource="source $HOME/.bashrc" + +export STM32_PRG_PATH=/home/nicholasmello/STMicroelectronics/STM32Cube/STM32CubeProgrammer/binexport PATH="/home/nicholasmello/.pixi/bin:$PATH" diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..6662d7a --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,5 @@ +if status is-interactive + if type -q fzf + fzf --fish | source + end +end diff --git a/fish/fish_variables b/fish/fish_variables new file mode 100644 index 0000000..d418b7a --- /dev/null +++ b/fish/fish_variables @@ -0,0 +1,31 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3800 +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:green +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:brcyan +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:brcyan +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold +SETUVAR fish_color_search_match:white\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:yellow\x1e\x2di +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_selected_background:\x2dr diff --git a/fish/functions/list-archive-contents.fish b/fish/functions/list-archive-contents.fish new file mode 100644 index 0000000..3ad068f --- /dev/null +++ b/fish/functions/list-archive-contents.fish @@ -0,0 +1,134 @@ +function list-archive-contents --description "Recursively list contents of zip and tar archives" + argparse --name=list-archive-contents h/help 'o=' -- $argv + or return 1 + + function print_help + echo " +Usage: list-archive-contents [-h] [-o output_file] archive1 [archive2 ...] + +Recursively lists the contents of zip and tar files, including nested archives. + +Options: + -h, --help Show this help message and exit + -o output_file Write output to the specified file instead of printing +" + end + + if set -q _flag_help + print_help + return 0 + end + + set -g output_file "" + if set -q _flag_o + set output_file $_flag_o + rm -rf $output_file + end + + set -l args $argv + + if test (count $args) -eq 0 + print_help + return 0 + end + + # Print indentation as real tabs + function _indent + set -l level $argv[1] + printf "%s" (string repeat $level " ") + end + + # Print line with indentation, to file or stdout + function _print + set -l depth $argv[1] + set -l message $argv[2..-1] + set -l indent (_indent $depth) + if test -n "$output_file" + printf "%s%s\n" $indent $message >>"$output_file" + else + printf "%s%s\n" $indent $message + end + end + + function list_contents_recursive + set -l file $argv[1] + set -l depth $argv[2] + + if not test -f "$file" + _print $depth "File not found: $file" + return + end + + # Show only basename in header to hide /tmp/ + set -l display_file (basename -- "$file") + _print $depth "📦 $display_file" + + set -l ext (string lower $display_file) + + switch $ext + case '*.zip' + set -l tmpdir (mktemp -d) + unzip -q "$file" -d "$tmpdir" + + # Gather nested archives + set -l nested_archives (find "$tmpdir" -type f \( -iname '*.zip' -o -iname '*.tar' -o -iname '*.tar.gz' -o -iname '*.tgz' -o -iname '*.tar.bz2' -o -iname '*.tbz2' -o -iname '*.tar.xz' -o -iname '*.txz' \)) + + # Print normal files (excluding nested archives) + find "$tmpdir" -type f | while read -l inner + if contains -- "$inner" $nested_archives + continue + end + set -l relpath (string replace -- "$tmpdir/" "" "$inner") + _print (math $depth + 1) "$relpath" + end + + # Recurse into each nested archive + for nested in $nested_archives + list_contents_recursive "$nested" (math $depth + 1) + end + + rm -rf "$tmpdir" + + case '*.tar' '*.tar.gz' '*.tgz' '*.tar.bz2' '*.tbz2' '*.tar.xz' '*.txz' + set -l tmpdir (mktemp -d) + switch $ext + case '*.tar' + tar -xf "$file" -C "$tmpdir" + case '*.tar.gz' '*.tgz' + tar -xzf "$file" -C "$tmpdir" + case '*.tar.bz2' '*.tbz2' + tar -xjf "$file" -C "$tmpdir" + case '*.tar.xz' '*.txz' + tar -xJf "$file" -C "$tmpdir" + end + + # Find nested archives in extracted tree + set -l nested_archives (find "$tmpdir" -type f \( -iname '*.zip' -o -iname '*.tar' -o -iname '*.tar.gz' -o -iname '*.tgz' -o -iname '*.tar.bz2' -o -iname '*.tbz2' -o -iname '*.tar.xz' -o -iname '*.txz' \)) + + # Print all files except nested archives themselves + find "$tmpdir" -type f | while read -l inner + if contains -- "$inner" $nested_archives + continue + end + set -l relpath (string replace -- "$tmpdir/" "" "$inner") + _print (math $depth + 1) "$relpath" + end + + # Recurse into nested archives + for nested in $nested_archives + list_contents_recursive "$nested" (math $depth + 1) + end + + rm -rf "$tmpdir" + + case '*' + _print $depth "❌ Unsupported file format: $file" + end + end + + for arg in $args + for file in (eval echo $arg) + list_contents_recursive "$file" 0 + end + end +end diff --git a/fish/functions/vi.fish b/fish/functions/vi.fish new file mode 100644 index 0000000..cc64b52 --- /dev/null +++ b/fish/functions/vi.fish @@ -0,0 +1,3 @@ +function vi --wraps nvim --description "Alias for neovim" + nvim $argv +end diff --git a/git/gitconfig b/git/gitconfig new file mode 100644 index 0000000..e775af4 --- /dev/null +++ b/git/gitconfig @@ -0,0 +1,11 @@ +[user] + name = Nick Mello + email = nick@nmello.dev + signingkey = A4007252A92585A8 +[commit] + template = /home/nicholasmello/.gitmessage + gpgsign = true +[merge] + tool = vimdiff +[gpg] + program = gpg diff --git a/git/gitmessage b/git/gitmessage new file mode 100644 index 0000000..d25df03 --- /dev/null +++ b/git/gitmessage @@ -0,0 +1,7 @@ +# Title: Summary, imperative, start upper case, don't end with a period +# No more than 50 chars. #### 50 chars is here: # + +# Body: Explain *what* and *why* (not *how*). Include task ID (Jira issue). +# Wrap at 72 chars. ################################## which is here: # + +Signed-off-by: Nicholas Mello diff --git a/nvim/.editorconfig b/nvim/.editorconfig new file mode 100644 index 0000000..8ee01f6 --- /dev/null +++ b/nvim/.editorconfig @@ -0,0 +1,47 @@ +# EditorConfig is awesome: https://editorconfig.org + +root = true + +# Neovim Lua config files +[*.lua] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# Vim script files +[*.vim] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# Shell scripts +[*.sh] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# Markdown files +[*.md] +trim_trailing_whitespace = false +insert_final_newline = true +charset = utf-8 + +# Git commit messages +[COMMIT_EDITMSG] +trim_trailing_whitespace = false +insert_final_newline = true +charset = utf-8 + +# Generic defaults for other text files +[*] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..a130607 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,52 @@ +vim.opt.mouse = "" + +vim.opt.wildmode = "longest,list" + +vim.opt.list = true +vim.opt.listchars = "tab:>-,trail:-,extends:#,nbsp:-" + +vim.opt.ignorecase = true -- case insensitive search +vim.opt.smartcase = true -- case sensitive when uc present +vim.opt.modeline = true -- Search files for local settings such as nowrap +vim.opt.laststatus = 2 -- Always show the status line at the bottom of the window + +vim.opt.colorcolumn = "80" +vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg = 232, bg = 232 }) + +vim.opt.clipboard = "unnamedplus" +vim.wo.relativenumber = true + +vim.g.mapleader = ";" + +-- Get rid of highlighting with enter +vim.keymap.set("n", "", "noh") + +-- Leader Bindings +vim.g.mapleader = ";" +vim.keymap.set('n', 'tc', 'tabnew') +vim.keymap.set('n', 'tn', 'tabnext') +vim.keymap.set('n', 'tp', 'tabprevious') +vim.keymap.set('n', 'tN', 'tabprevious') +vim.keymap.set('n', 'z', '|_') +vim.keymap.set('n', '', '=') +vim.keymap.set('n', 'h', 'h') +vim.keymap.set('n', 'j', 'j') +vim.keymap.set('n', 'k', 'k') +vim.keymap.set('n', 'l', 'l') + +vim.diagnostic.config({ + virtual_text = { + prefix = '>>', -- or any symbol you prefer + spacing = 1, + -- position diagnostics at end of line: + virt_text_pos = "eol", + }, + signs = true, + underline = true, + update_in_insert = false, + severity_sort = true, +}) + +require("bootstrap") -- Bootstrap lazy.nvim and load all plugins +require("whitespace") -- Adds autocmd to remove whitespace +require("jk") -- Adds jk escape diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..0d0f601 --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,16 @@ +{ + "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "fzf.vim": { "branch": "master", "commit": "3725f364ccd25b85a91970720ba9bc2931861910" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-lspconfig": { "branch": "master", "commit": "f0c6ccf43997a1c7e9ec4aea36ffbf2ddd9f15ef" }, + "oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" } +} diff --git a/nvim/lua/bootstrap.lua b/nvim/lua/bootstrap.lua new file mode 100644 index 0000000..0133dfb --- /dev/null +++ b/nvim/lua/bootstrap.lua @@ -0,0 +1,74 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +local offline_marker = vim.fn.stdpath("config") .. "/.offline" + +-- Define your functions first + +local function is_offline() + return vim.fn.filereadable(offline_marker) == 1 +end + +local function set_offline() + local f = io.open(offline_marker, "w") + if f then + f:write("offline\n") + f:close() + end +end + +local function clear_offline() + os.remove(offline_marker) +end + +local function has_network() + local handle = io.popen("ping -c 1 github.com 2>/dev/null") + if handle then + local result = handle:read("*a") + handle:close() + return result and #result > 0 + end + return false +end + +local function install_lazy() + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) + print("lazy.nvim installed!") +end + +-- Now call the functions + +if not vim.loop.fs_stat(lazypath) then + if is_offline() then + print("Offline mode enabled. Skipping lazy.nvim install.") + return + else + if has_network() then + install_lazy() + clear_offline() + else + print("No network detected. Enabling offline mode.") + set_offline() + return + end + end +end + +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, +}) + +vim.api.nvim_create_user_command("GoOnline", function() + clear_offline() + print(".offline marker cleared. Restart Neovim to attempt plugin install again.") +end, {}) diff --git a/nvim/lua/jk.lua b/nvim/lua/jk.lua new file mode 100644 index 0000000..1f58035 --- /dev/null +++ b/nvim/lua/jk.lua @@ -0,0 +1,36 @@ +local timer = nil +local waiting_for_k = false + +local function cancel_timer() + if timer then + timer:stop() + timer:close() + timer = nil + end + waiting_for_k = false +end + +vim.keymap.set({"i", "t"}, "j", function() + if waiting_for_k then + return "j" + end + + waiting_for_k = true + + local timeout = vim.o.timeoutlen + timer = vim.loop.new_timer() + timer:start(timeout, 0, vim.schedule_wrap(function() + cancel_timer() + end)) + + return "j" +end, { expr = true, noremap = true }) + +vim.keymap.set({"i", "t"}, "k", function() + if waiting_for_k then + cancel_timer() + return "" + else + return "k" + end +end, { expr = true, noremap = true }) diff --git a/nvim/lua/plugins/autopairs.lua b/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..06228d7 --- /dev/null +++ b/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function +} diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..774055d --- /dev/null +++ b/nvim/lua/plugins/completion.lua @@ -0,0 +1,45 @@ +return { + 'saghen/blink.cmp', + dependencies = { 'rafamadriz/friendly-snippets' }, + + version = '1.*', + + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'super-tab' }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = false } }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { 'lsp', 'snippets', 'path', 'buffer' }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" } + }, + opts_extend = { "sources.default" } +} diff --git a/nvim/lua/plugins/explorer.lua b/nvim/lua/plugins/explorer.lua new file mode 100644 index 0000000..b736a24 --- /dev/null +++ b/nvim/lua/plugins/explorer.lua @@ -0,0 +1,29 @@ +return { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = { + float = { + max_width = math.floor(vim.o.columns * 0.6), + max_height = math.floor(vim.o.lines * 0.6), + border = "rounded", + } + }, + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + + keys = { + { + "e", + function() + require("oil").open_float() + end, + desc = "Open Oil floating window", + noremap = true, + silent = true, + }, + }, +} diff --git a/nvim/lua/plugins/git.lua b/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..1d6ad7a --- /dev/null +++ b/nvim/lua/plugins/git.lua @@ -0,0 +1,20 @@ +return { + { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup({ + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + numhl = false, + linehl = false, + watch_gitdir = { interval = 1000 }, -- auto-refresh + attach_to_untracked = true, + }) + end, + }, +} diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..2e615ef --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,53 @@ +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format() + end, +}) + +return { + { + "neovim/nvim-lspconfig", + dependencies = { + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, + }, + config = function() + local lspconfig = require("lspconfig") + + lspconfig.lua_ls.setup {} + + lspconfig.pyright.setup {} + + lspconfig.bashls.setup {} + + lspconfig.fish_lsp.setup {} + + lspconfig.rust_analyzer.setup { + root_dir = function(fname) + -- Look for Cargo.toml to define project root + return lspconfig.util.root_pattern("Cargo.toml")(fname) + end, + settings = { + ["rust-analyzer"] = { + cargo = { allFeatures = true }, + checkOnSave = { command = "clippy" }, -- Run linter + } + } + } + end, + }, + { + -- Quickly install LSPs with internet connection + "mason-org/mason.nvim", + opts = {} + }, +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..4308cc9 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,28 @@ +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + cmd = "Telescope", + keys = { + { 'f', 'Telescope find_files', mode = { "n" }, desc = "Telescope find_files" }, + { 'b', 'Telescope buffers', mode = { "n" }, desc = "Telescope buffers" }, + { 'g', 'Telescope grep_string', mode = { "n" }, desc = "Telescope grep_string" }, + { 'r', 'Telescope live_grep', mode = { "n" }, desc = "Telescope live_grep" }, + { ';', 'Telescope', mode = { "n" }, desc = "Telescope options" }, + }, + config = {}, + }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + dependencies = {'nvim-telescope/telescope.nvim'}, + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release', + config = function() + require('telescope').load_extension('fzf') + end, + }, + { + 'junegunn/fzf.vim', + event = "VeryLazy", + } +} diff --git a/nvim/lua/whitespace.lua b/nvim/lua/whitespace.lua new file mode 100644 index 0000000..1f2731a --- /dev/null +++ b/nvim/lua/whitespace.lua @@ -0,0 +1,12 @@ +-- RemoveWhitespace +vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("RemoveWhitespace", { clear = true }), + pattern = "*", -- Handle pattern myself in callback + callback = function() + if vim.bo.filetype == "diff" then + return + end + -- Failure to find is not a real failure, silence failures + vim.api.nvim_command("silent! " .. "%s/\\s\\+$//") + end, +}) diff --git a/tmux/tmux.conf b/tmux/tmux.conf new file mode 100644 index 0000000..9380031 --- /dev/null +++ b/tmux/tmux.conf @@ -0,0 +1,29 @@ +set -g default-terminal "xterm-256color" +set-option -g repeat-time 0 +set-option -g history-limit 50000 +set-window-option -g mode-keys vi + +# Clipboard +set -s set-clipboard external + +# Periodically set pane names +set-option -g status-interval 5 +set-option -g automatic-rename on +set-option -g automatic-rename-format '#{b:pane_current_path}' + +# Keep same directory when creating new window +bind c new-window -c "#{pane_current_path}" +bind '"' split-window -c "#{pane_current_path}" +bind % split-window -h -c "#{pane_current_path}" + +# Quick reload +bind R source-file ~/.tmux.conf \; display "Reloaded tmux.conf" + +# tmux power +set -g @plugin 'wfxr/tmux-power' +set -g @tmux_power_theme 'coral' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +run '~/.tmux/plugins/tpm/tpm'