├── .gitignore
├── README.md
├── alacritty
└── .config
│ └── alacritty
│ ├── alacritty.yml
│ └── xterm-256color.terminfo
├── bspwm
└── .config
│ └── bspwm
│ ├── bspwmrc
│ ├── bspwmrc-msi
│ └── external_rules
├── dunst
└── .config
│ └── dunst
│ └── dunstrc
├── flameshot
└── .config
│ └── flameshot
│ └── flameshot.ini
├── home
├── .bashrc
└── scripts
│ └── install
│ ├── install_env.sh
│ ├── install_neovim.sh
│ └── install_neovim_config.sh
├── kitty
└── .config
│ └── kitty
│ └── kitty.conf
├── latexmk
└── .config
│ └── latexmk
│ └── latexmkrc
├── list.txt
├── mpv
└── .config
│ └── mpv
│ ├── .gitignore
│ └── mpv.conf
├── neovim
└── .config
│ └── nvim
│ ├── Dockerfile
│ ├── actions.json
│ ├── after
│ ├── ftplugin
│ │ ├── cpp.lua
│ │ ├── oil_preview.lua
│ │ ├── python.lua
│ │ ├── tex.lua
│ │ └── tom.lua
│ └── plugin
│ │ ├── apm.lua
│ │ ├── async_make.lua
│ │ ├── image_paste.lua
│ │ ├── lsp-on-type-formatting.lua
│ │ ├── python-cc.lua
│ │ ├── python-env.lua
│ │ ├── tex_formatter.lua
│ │ └── zoom.lua
│ ├── compiler
│ └── python.vim
│ ├── init.lua
│ ├── lazy-lock.json
│ ├── lua
│ ├── plugins
│ │ ├── init.lua
│ │ ├── modules.lua
│ │ └── modules
│ │ │ ├── barbecue.lua
│ │ │ ├── bufferline.lua
│ │ │ ├── chatgpt.lua
│ │ │ ├── cmp.lua
│ │ │ ├── colorizer.lua
│ │ │ ├── comment.lua
│ │ │ ├── copilot.lua
│ │ │ ├── dap.lua
│ │ │ ├── diffview.lua
│ │ │ ├── dressing.lua
│ │ │ ├── gitsigns.lua
│ │ │ ├── harpoon.lua
│ │ │ ├── image.lua
│ │ │ ├── local-highlight.lua
│ │ │ ├── lsp
│ │ │ ├── custom
│ │ │ │ ├── init.lua
│ │ │ │ ├── null-ls.lua
│ │ │ │ ├── pylance.lua
│ │ │ │ └── wolfram_ls.lua
│ │ │ ├── handlers.lua
│ │ │ ├── init.lua
│ │ │ ├── mappings.lua
│ │ │ ├── null-ls.lua
│ │ │ ├── servers.lua
│ │ │ └── settings.lua
│ │ │ ├── lualine.lua
│ │ │ ├── luasnip
│ │ │ ├── init.lua
│ │ │ ├── mappings.lua
│ │ │ ├── settings.lua
│ │ │ └── snips
│ │ │ │ ├── cmake.lua
│ │ │ │ ├── cpp.lua
│ │ │ │ ├── lua.lua
│ │ │ │ ├── python.lua
│ │ │ │ ├── tex.lua
│ │ │ │ └── tex_math.lua
│ │ │ ├── navic.lua
│ │ │ ├── neogen.lua
│ │ │ ├── neogit.lua
│ │ │ ├── neotest.lua
│ │ │ ├── neotree.lua
│ │ │ ├── noice.lua
│ │ │ ├── notify.lua
│ │ │ ├── nvim-tree.lua
│ │ │ ├── obsidian.lua
│ │ │ ├── oil.lua
│ │ │ ├── peek.lua
│ │ │ ├── spectre.lua
│ │ │ ├── surround.lua
│ │ │ ├── telescope.lua
│ │ │ ├── tmux.lua
│ │ │ ├── toggleterm.lua
│ │ │ ├── tokyodark.lua
│ │ │ ├── treesitter.lua
│ │ │ ├── trouble.lua
│ │ │ └── which-key.lua
│ ├── tiagovla
│ │ ├── autocmds.lua
│ │ ├── commands.lua
│ │ ├── globals.lua
│ │ ├── init.lua
│ │ ├── mappings.lua
│ │ ├── settings.lua
│ │ └── utils.lua
│ └── utils
│ │ ├── linkedlist.lua
│ │ └── watcher.lua
│ ├── spell
│ └── en.utf-8.add
│ └── templates
│ ├── cmake
│ ├── make
│ └── tex.tex
├── picom
└── .config
│ └── picom
│ ├── launch.sh
│ └── picom.conf
├── polybar
└── .config
│ └── polybar
│ ├── config.ini
│ ├── config_side.ini
│ ├── launch.sh
│ └── scripts
│ ├── bluetooth_battery.sh
│ ├── mic.sh
│ ├── spotify.sh
│ └── toggl
├── redshift
└── .config
│ └── redshift.conf
├── rofi
└── .config
│ └── rofi
│ ├── colors.rasi
│ ├── config.rasi
│ ├── config1.rasi
│ ├── dmenu.rasi
│ ├── launcher.rasi
│ └── zotero.rasi
├── root
└── etc
│ ├── X11
│ └── xorg.conf.d
│ │ └── 69-keyboard.conf
│ ├── default
│ └── grub
│ └── udev
│ └── rules.d
│ ├── 99-keyboard.rules
│ ├── 99-monitor-hotplug.rules
│ └── 99-power-energy.rules
├── scripts
└── .local
│ └── bin
│ ├── audible2mp3
│ ├── ez
│ ├── fan_speed
│ ├── fix_layout
│ ├── imgur
│ ├── kbd_layout
│ ├── monitor_setup
│ ├── notflix
│ ├── profile
│ ├── rcloud
│ └── transfer
├── stylua
└── .config
│ └── .stylua.toml
├── sxhkd
└── .config
│ └── sxhkd
│ └── sxhkdrc
├── systemd
└── .config
│ └── systemd
│ └── user
│ ├── keyboard-layout.service
│ └── monitor-hotplug.service
├── tmux
└── .config
│ └── tmux
│ ├── .gitignore
│ ├── screen-256color.terminfo
│ └── tmux.conf
├── wezterm
└── .config
│ └── wezterm
│ └── wezterm.lua
├── x
├── .xinitrc
└── .xprofile
├── zathura
└── .config
│ └── zathura
│ └── zathurarc
└── zsh
├── .config
└── zsh
│ ├── .gitignore
│ ├── .zshrc
│ └── config
│ ├── .gitignore
│ ├── aliases.zsh
│ ├── exports.zsh
│ ├── functions.zsh
│ ├── mappings.zsh
│ ├── plugins.zsh
│ ├── prompt.zsh
│ └── settings.zsh
└── .zshenv
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | */*/mpv/watch_later/
3 | */*/packer_compiled.lua
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .dotfiles
2 |
3 | ## Installation
4 | ```bash
5 | stow */
6 | ```
7 | ## Images
8 |
9 | 
10 | 
11 | 
12 | 
13 | 
14 |
15 | ## Firefox theme:
16 | https://addons.mozilla.org/firefox/addon/tokyodark/
17 |
--------------------------------------------------------------------------------
/alacritty/.config/alacritty/alacritty.yml:
--------------------------------------------------------------------------------
1 | window:
2 | padding:
3 | x: 4
4 | y: 2
5 | title: Terminal
6 | class:
7 | instance: Alacritty
8 | general: Alacritty
9 |
10 | scrolling:
11 | history: 10000
12 | font:
13 | normal:
14 | family: MonoLisa Nerd Font
15 | style: Medium
16 | bold:
17 | family: MonoLisa Nerd Font
18 | style: Bold
19 | italic:
20 | family: MonoLisa Nerd Font
21 | style: MediumItalic
22 | bold_italic:
23 | family: MonoLisa Nerd Font
24 | style: BoldItalic
25 | size: 10.0
26 |
27 | draw_bold_text_with_bright_colors: true
28 |
29 | colors:
30 | primary:
31 | background: "#11121D"
32 | foreground: "#a0A8CD"
33 | normal:
34 | black: "#32344a"
35 | red: "#f7768e"
36 | green: "#9ece6a"
37 | yellow: "#e0af68"
38 | blue: "#7aa2f7"
39 | magenta: "#ad8ee6"
40 | cyan: "#449dab"
41 | white: "#787c99"
42 | bright:
43 | black: "#444b6a"
44 | red: "#ff7a93"
45 | green: "#b9f27c"
46 | yellow: "#ff9e64"
47 | blue: "#7da6ff"
48 | magenta: "#bb9af7"
49 | cyan: "#0db9d7"
50 | white: "#acb0d0"
51 |
52 | # background_opacity: 1.0
53 |
54 | selection:
55 | save_to_clipboard: false
56 |
57 | live_config_reload: true
58 |
59 | shell:
60 | program: /usr/bin/zsh
61 | args:
62 | - -l
63 | - -c
64 | - "tmux attach -t $(bspc query -D -d focused --names) || tmux new-session -A -s $(bspc query -D -d focused --names)"
65 |
66 | key_bindings:
67 | - { key: I, mods: Control, chars: "\x1b[105;5u" }
68 | - { key: Return, mods: Shift, chars: "\x1b[13;2u" }
69 | - { key: Return, mods: Control, chars: "\x1b[13;5u" }
70 |
--------------------------------------------------------------------------------
/alacritty/.config/alacritty/xterm-256color.terminfo:
--------------------------------------------------------------------------------
1 | # A screen-256color based TERMINFO that adds the escape sequences for italic.
2 | #
3 | # Install:
4 | #
5 | # tic screen-256color.terminfo
6 | #
7 | # Usage:
8 | #
9 | # export TERM=screen-256color
10 | #
11 | xterm-256color-italic|xterm with 256 colors and italic,
12 | sitm=\E[3m, ritm=\E[23m,
13 | use=xterm-256color,
14 |
--------------------------------------------------------------------------------
/bspwm/.config/bspwm/bspwmrc:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | _run() {
4 | pgrep -x "${1}" > /dev/null || "$@" &
5 | }
6 |
7 | _run dbus-update-activation-environment --all
8 | _run sxhkd
9 |
10 | bspc monitor "eDP-1" -d 1 2 3 4 5 6 7 8 9 0 10 11
11 | bspc config border_width 2
12 | bspc config borderless_monocle true
13 | bspc config focused_border_color "#353b45"
14 | bspc config gapless_monocle true
15 | bspc config normal_border_color "#282c34"
16 | bspc config single_monocle false
17 | bspc config split_ratio 0.50
18 | bspc config top_padding 20
19 | bspc config window_gap 4
20 | bspc config remove_disabled_monitors true
21 | bspc config remove_unplugged_monitors true
22 | bspc config merge_overlapping_monitors true
23 | bspc config pointer_modifier mod1
24 | bspc config pointer_action1 move
25 | bspc config pointer_action2 resize_side
26 | bspc config pointer_action2 resize_corner
27 | bspc config focus_follows_pointer true
28 | bspc config external_rules_command "${HOME}/.config/bspwm/external_rules"
29 | bspc config pointer_motion_interval 40
30 |
31 | _run xbanish
32 | _run dunst
33 | _run flameshot
34 | _run copyq
35 | _run picom
36 | _run nm-applet
37 | _run xsetroot -cursor_name left_ptr
38 | _run redshift
39 | _run polybar main
40 | _run solaar --window=hide
41 | _run localsend --hidden
42 | _run bitwarden-desktop autostart
43 | _run aw-qt --no-gui
44 | _run feh --bg-scale ~/Pictures/arch.png
45 | _run autorandr --change
46 | _run xset r rate 200 200
47 |
--------------------------------------------------------------------------------
/bspwm/.config/bspwm/bspwmrc-msi:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | _run() {
4 | pgrep -x "${1}" >/dev/null || "$@" &
5 | }
6 |
7 | _run sxhkd
8 |
9 | IS_CONNECTED=$(xrandr | grep ' connected' | grep 'HDMI' | awk '{print $1}')
10 | EXTERNAL_MONITOR="HDMI-1-1"
11 | INTERNAL_MONITOR=$(xrandr | grep 'eDP' | awk '{print $1}')
12 |
13 | if [[ $1 == 0 ]]; then
14 | if [[ -n $IS_CONNECTED ]]; then
15 | (
16 | sleep 1
17 | xrandr --output "$EXTERNAL_MONITOR" --mode 2560x1080 --rate 75 --primary --right-of "$INTERNAL_MONITOR" --output "$main_monitor" --off
18 | bspc monitor "$INTERNAL_MONITOR" -d 10
19 | bspc monitor "$EXTERNAL_MONITOR" -d 1 2 3 4 5 6 7 8 9 0
20 | bspc wm -O "$EXTERNAL_MONITOR" "$INTERNAL_MONITOR"
21 | # bspc wm -O "HDMI-1-1" "eDP-1"
22 | ) &
23 | else
24 | bspc monitor "$INTERNAL_MONITOR" -d 1 2 3 4 5 6 7 8 9 0 10
25 | fi
26 | fi
27 |
28 | bspc config border_width 2
29 | bspc config borderless_monocle true
30 | bspc config focused_border_color "#353b45"
31 | bspc config gapless_monocle true
32 | bspc config normal_border_color "#282c34"
33 | bspc config single_monocle false
34 | bspc config split_ratio 0.50
35 | bspc config top_padding 20
36 | bspc config window_gap 8
37 |
38 | bspc config external_rules_command "${HOME}/.config/bspwm/external_rules"
39 |
40 | bspc config pointer_modifier mod1
41 | bspc config pointer_action1 move
42 | bspc config pointer_action2 resize_side
43 | bspc config pointer_action2 resize_corner
44 | bspc config focus_follows_pointer true
45 |
46 | _run xbanish
47 | _run dunst
48 | _run flameshot
49 | # _run picom
50 | _run nm-applet
51 | _run clipcatd
52 | _run redshift
53 |
54 | (
55 | _run kbd_layout
56 | _run xsetroot -cursor_name left_ptr
57 | _run xset r rate 200 120
58 | monitor_setup
59 | feh --bg-scale ~/Pictures/wallpaper.png
60 | ) &
61 |
62 | if [[ -n $IS_CONNECTED ]]; then
63 | bspc monitor "$INTERNAL_MONITOR" -g 1920x1080+0+0
64 | else
65 | bspc monitor "$INTERNAL_MONITOR" -g 1920x1080+0+0
66 | bspc monitor "$EXTERNAL_MONITOR" -g 2560x1080+0+0
67 | fi
68 |
--------------------------------------------------------------------------------
/dunst/.config/dunst/dunstrc:
--------------------------------------------------------------------------------
1 | [global]
2 | monitor = 0
3 | follow = mouse
4 | width = 400
5 | offset = 20x50
6 | origin = top-right
7 | progress_bar = true
8 | progress_bar_height = 10
9 | progress_bar_frame_width = 1
10 | progress_bar_min_width = 150
11 | progress_bar_max_width = 400
12 | indicate_hidden = false
13 | notification_limit = 0
14 | shrink = no
15 | transparency = 0
16 | separator_height = 2
17 | padding = 8
18 | horizontal_padding = 8
19 | text_icon_padding = 0
20 | frame_width = 1
21 | frame_color = "#4A5057"
22 | separator_color = frame
23 | sort = yes
24 | font = MonoLisa 12
25 | line_height = 1
26 | markup = full
27 | format = "%a\n%s\n%b"
28 | alignment = left
29 | vertical_alignment = center
30 | show_age_threshold = 60
31 | word_wrap = yes
32 | ellipsize = middle
33 | ignore_newline = no
34 | stack_duplicates = true
35 | hide_duplicate_count = false
36 | show_indicators = yes
37 | icon_position = left
38 | min_icon_size = 0
39 | max_icon_size = 64
40 | icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/
41 | icon_theme = "Tela-circle, Adwaita"
42 | enable_recursive_icon_lookup = true
43 | sticky_history = yes
44 | history_length = 20
45 | always_run_script = true
46 | title = Dunst
47 | class = Dunst
48 | ignore_dbusclose = false
49 | mouse_left_click = do_action, close_current
50 | mouse_middle_click = do_action, close_current
51 | mouse_right_click = close_all
52 | browser = /usr/bin/xdg-open
53 |
54 | [urgency_low]
55 | background = "#11121D"
56 | foreground = "#A0A8CD"
57 | timeout = 15
58 |
59 | [urgency_normal]
60 | background = "#11121D"
61 | foreground = "#A0A8CD"
62 | timeout = 25
63 |
64 | [urgency_critical]
65 | background = "#11121D"
66 | foreground = "#EE6D85"
67 | timeout = 35
68 |
69 | ; vim:ft=dosini
70 |
--------------------------------------------------------------------------------
/flameshot/.config/flameshot/flameshot.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | contrastOpacity=188
3 | drawColor=#800080
4 | drawFontSize=32
5 | drawThickness=16
6 | ignoreUpdateToVersion=12.0.0
7 | savePath=/home/tiagovla
8 |
--------------------------------------------------------------------------------
/home/.bashrc:
--------------------------------------------------------------------------------
1 | #
2 | # ~/.bashrc
3 | #
4 |
5 | # If not running interactively, don't do anything
6 | [[ $- != *i* ]] && return
7 |
8 | alias ls='ls --color=auto'
9 | PS1='[\u@\h \W]\$ '
10 |
11 | export PATH="$HOME/.pyenv/bin:$PATH"
12 | eval "$(pyenv init -)"
13 | eval "$(pyenv virtualenv-init -)"
14 |
15 | export PATH="$HOME/.poetry/bin:$PATH"
16 |
--------------------------------------------------------------------------------
/home/scripts/install/install_env.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if uname -a | grep -q Ubuntu; then
4 | echo "Installing dependencies on ubuntu..."
5 | sudo apt-get install zsh golang-go nodejs npm \
6 | make build-essential libssl-dev zlib1g-dev \
7 | libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
8 |
9 | elif [ -f "/etc/arch-release" ]; then
10 | echo "Installing dependencies on arch..."
11 | sudo pacman -S zsh go
12 | fi
13 |
14 | # update tmux config
15 | curl https://raw.githubusercontent.com/tiagovla/dotfiles/master/.tmux.conf >"$HOME/.tmux.conf"
16 |
17 | # update bash config
18 | curl https://raw.githubusercontent.com/tiagovla/dotfiles/master/.bashrc >"$HOME/.bashrc"
19 | source "$HOME/.bashrc"
20 |
21 | # pyenv
22 | if ! command -v pyenv &>/dev/null; then
23 | rm "$HOME/.pyenv" -rf
24 | git clone https://github.com/pyenv/pyenv.git ~/.pyenv
25 | pyenv install 3.9.4
26 | pyenv install 2.7.18
27 | pyenv global 3.9.4 2.7.18
28 | fi
29 |
30 | # poetry
31 | if ! command -v poetry &>/dev/null; then
32 | curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
33 | fi
34 |
35 | # zsh
36 | if ! command -v zsh &>/dev/null; then
37 | # install ohmyzsh
38 | sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
39 | # update zsh config
40 | curl https://raw.githubusercontent.com/tiagovla/dotfiles/master/.zshrc >"$HOME/.zshrc"
41 | source "$HOME/.zshrc"
42 | fi
43 |
--------------------------------------------------------------------------------
/home/scripts/install/install_neovim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if uname -a | grep -q Ubuntu; then
4 | echo "Installing dependencies on ubuntu..."
5 | sudo apt-get install ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip
6 | elif [ -f "/etc/arch-release" ]; then
7 | echo "Installing dependencies on arch..."
8 | sudo pacman -S base-devel cmake unzip ninja tree-sitter
9 | fi
10 |
11 | TMP_DIR=$(mktemp -d)
12 | if [ ! -e "$TMP_DIR" ]; then
13 | echo >&2 "Failed to create temp directory."
14 | exit 1
15 | fi
16 | trap "exit 1" HUP INT PIPE QUIT TERM
17 | trap 'rm -rf "$TMP_DIR"' EXIT
18 | echo "Created temporary directory $TMP_DIR."
19 |
20 | NEOVIM_TMP_DIR="$TMP_DIR/neovim"
21 |
22 | git clone https://github.com/neovim/neovim.git "$NEOVIM_TMP_DIR"
23 | cd "$NEOVIM_TMP_DIR" || exit 1
24 | make CMAKE_BUILD_TYPE=RelWithDebInfo
25 | sudo make install
26 | cd - >/dev/null || exit 1
27 |
--------------------------------------------------------------------------------
/home/scripts/install/install_neovim_config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | TMP_DIR=$(mktemp -d)
4 | if [ ! -e "$TMP_DIR" ]; then
5 | echo >&2 "Failed to create temp directory."
6 | exit 1
7 | fi
8 | trap "exit 1" HUP INT PIPE QUIT TERM
9 | trap 'rm -rf "$TMP_DIR"' EXIT
10 | echo "Created temporary directory $TMP_DIR."
11 |
12 | DOTFILES_TMP_DIR="$TMP_DIR/dotfiles"
13 | HOME_CONFIG_DIR="$HOME/.config"
14 | HOME_CONFIG_NVIM_DIR="${HOME_CONFIG_DIR}/nvim"
15 |
16 | clone_dotfiles() {
17 | echo "Cloning dotfiles..."
18 | git clone \
19 | --depth 1 \
20 | --filter=blob:none \
21 | --no-checkout \
22 | https://github.com/tiagovla/dotfiles.git \
23 | "$DOTFILES_TMP_DIR" \
24 | ;
25 | cd "$DOTFILES_TMP_DIR" || exit
26 | git sparse-checkout init --cone
27 | git sparse-checkout set nvim
28 | git checkout master
29 | cd - >/dev/null || exit
30 | }
31 |
32 | backup_nvim() {
33 | TIMENOW=$(date +"%s")
34 | BACKUP_PATH="${HOME_CONFIG_NVIM_DIR}_${TIMENOW}_bk"
35 | mv "$HOME_CONFIG_NVIM_DIR" "$BACKUP_PATH" || exit
36 | echo "Your old neovim configuration $HOME_CONFIG_NVIM_DIR was moved to $BACKUP_PATH."
37 | }
38 |
39 | copy_nvim() {
40 | if [ -d "$HOME_CONFIG_NVIM_DIR" ]; then
41 | echo "Nvim config backup failed."
42 | exit
43 | else
44 | echo "New configuration copied to ${HOME_CONFIG_NVIM_DIR}."
45 | mkdir -p "$HOME_CONFIG_DIR"
46 | cp -r "$DOTFILES_TMP_DIR/nvim" "$HOME_CONFIG_NVIM_DIR"
47 | fi
48 | }
49 |
50 | install_packer() {
51 | git clone \
52 | "https://github.com/wbthomason/packer.nvim" \
53 | "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" \
54 | ;
55 | }
56 |
57 | ## Installation:
58 |
59 | #clone dotfiles from github
60 | clone_dotfiles
61 | #check if there is an old config
62 | [ -d "$HOME_CONFIG_NVIM_DIR" ] && backup_nvim
63 | #copy new configuration
64 | copy_nvim
65 |
66 | if [ -a "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]; then
67 | echo 'Packer already installed.'
68 | else
69 | install_packer
70 | fi
71 |
72 | nvim -u "$HOME_CONFIG_NVIM_DIR/init.lua" "+PackerInstall"
73 |
--------------------------------------------------------------------------------
/latexmk/.config/latexmk/latexmkrc:
--------------------------------------------------------------------------------
1 | $pdf_mode = 4;
2 | $postscript_mode = $dvi_mode = 0;
3 |
4 | add_cus_dep('glo', 'gls', 0, 'run_makeglossaries');
5 | add_cus_dep('acn', 'acr', 0, 'run_makeglossaries');
6 |
7 | sub run_makeglossaries {
8 | my ($base_name, $path) = fileparse( $_[0] );
9 | pushd $path;
10 | if ( $silent ) {
11 | system "makeglossaries -q '$base_name'"; #unix
12 | }
13 | else {
14 | system "makeglossaries '$base_name'"; #unix
15 | };
16 | popd;
17 | }
18 |
19 | push @generated_exts, 'glo', 'gls', 'glg';
20 | push @generated_exts, 'acn', 'acr', 'alg';
21 | $clean_ext .= ' %R.ist %R.xdy';
22 |
23 | # vim:ft=perl
24 |
--------------------------------------------------------------------------------
/mpv/.config/mpv/.gitignore:
--------------------------------------------------------------------------------
1 | watch_later/
2 |
--------------------------------------------------------------------------------
/mpv/.config/mpv/mpv.conf:
--------------------------------------------------------------------------------
1 | #
2 | # Example mpv configuration file
3 | #
4 | # Warning:
5 | #
6 | # The commented example options usually do _not_ set the default values. Call
7 | # mpv with --list-options to see the default values for most options. There is
8 | # no builtin or example mpv.conf with all the defaults.
9 | #
10 | #
11 | # Configuration files are read system-wide from /usr/local/etc/mpv.conf
12 | # and per-user from ~/.config/mpv/mpv.conf, where per-user settings override
13 | # system-wide settings, all of which are overridden by the command line.
14 | #
15 | # Configuration file settings and the command line options use the same
16 | # underlying mechanisms. Most options can be put into the configuration file
17 | # by dropping the preceding '--'. See the man page for a complete list of
18 | # options.
19 | #
20 | # Lines starting with '#' are comments and are ignored.
21 | #
22 | # See the CONFIGURATION FILES section in the man page
23 | # for a detailed description of the syntax.
24 | #
25 | # Profiles should be placed at the bottom of the configuration file to ensure
26 | # that settings wanted as defaults are not restricted to specific profiles.
27 |
28 | ##################
29 | # video settings #
30 | ##################
31 |
32 | # Start in fullscreen mode by default.
33 | #fs=yes
34 |
35 | # force starting with centered window
36 | #geometry=50%:50%
37 |
38 | # don't allow a new window to have a size larger than 90% of the screen size
39 | #autofit-larger=90%x90%
40 |
41 | # Do not close the window on exit.
42 | #keep-open=yes
43 |
44 | # Do not wait with showing the video window until it has loaded. (This will
45 | # resize the window once video is loaded. Also always shows a window with
46 | # audio.)
47 | #force-window=immediate
48 |
49 | # Disable the On Screen Controller (OSC).
50 | #osc=no
51 |
52 | # Keep the player window on top of all other windows.
53 | #ontop=yes
54 |
55 | # Specify high quality video rendering preset (for --vo=gpu only)
56 | # Can cause performance problems with some drivers and GPUs.
57 | #profile=gpu-hq
58 |
59 | # Force video to lock on the display's refresh rate, and change video and audio
60 | # speed to some degree to ensure synchronous playback - can cause problems
61 | # with some drivers and desktop environments.
62 | #video-sync=display-resample
63 |
64 | # Enable hardware decoding if available. Often, this does not work with all
65 | # video outputs, but should work well with default settings on most systems.
66 | # If performance or energy usage is an issue, forcing the vdpau or vaapi VOs
67 | # may or may not help.
68 | #hwdec=auto
69 |
70 | ##################
71 | # audio settings #
72 | ##################
73 |
74 | # Specify default audio device. You can list devices with: --audio-device=help
75 | # The option takes the device string (the stuff between the '...').
76 | #audio-device=alsa/default
77 |
78 | # Do not filter audio to keep pitch when changing playback speed.
79 | #audio-pitch-correction=no
80 |
81 | # Output 5.1 audio natively, and upmix/downmix audio with a different format.
82 | #audio-channels=5.1
83 | # Disable any automatic remix, _if_ the audio output accepts the audio format.
84 | # of the currently played file. See caveats mentioned in the manpage.
85 | # (The default is "auto-safe", see manpage.)
86 | #audio-channels=auto
87 |
88 | ##################
89 | # other settings #
90 | ##################
91 |
92 | # Pretend to be a web browser. Might fix playback with some streaming sites,
93 | # but also will break with shoutcast streams.
94 | #user-agent="Mozilla/5.0"
95 |
96 | # cache settings
97 | #
98 | # Use a large seekable RAM cache even for local input.
99 | #cache=yes
100 | #
101 | # Use extra large RAM cache (needs cache=yes to make it useful).
102 | #demuxer-max-bytes=500M
103 | #demuxer-max-back-bytes=100M
104 | #
105 | # Disable the behavior that the player will pause if the cache goes below a
106 | # certain fill size.
107 | #cache-pause=no
108 | #
109 | # Store cache payload on the hard disk instead of in RAM. (This may negatively
110 | # impact performance unless used for slow input such as network.)
111 | #cache-dir=~/.cache/
112 | #cache-on-disk=yes
113 |
114 | # Display English subtitles if available.
115 | #slang=en
116 |
117 | # Play Finnish audio if available, fall back to English otherwise.
118 | #alang=fi,en
119 |
120 | # Change subtitle encoding. For Arabic subtitles use 'cp1256'.
121 | # If the file seems to be valid UTF-8, prefer UTF-8.
122 | # (You can add '+' in front of the codepage to force it.)
123 | #sub-codepage=cp1256
124 |
125 | # You can also include other configuration files.
126 | #include=/path/to/the/file/you/want/to/include
127 |
128 | ############
129 | # Profiles #
130 | ############
131 |
132 | # The options declared as part of profiles override global default settings,
133 | # but only take effect when the profile is active.
134 |
135 | # The following profile can be enabled on the command line with: --profile=eye-cancer
136 |
137 | #[eye-cancer]
138 | #sharpen=5
139 | script-opts=osc-layout=bottombar,osc-vidscale=no
140 | save-position-on-quit
141 | ytdl-format=bestvideo[height<=480]+bestaudio/best[height<=480]
142 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:22.04 AS builder
2 |
3 | ARG BUILD_APT_DEPS="ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip git binutils"
4 | ARG DEBIAN_FRONTEND=noninteractive
5 |
6 | RUN apt update && apt upgrade -y && \
7 | apt install -y ${BUILD_APT_DEPS} && \
8 | git clone https://github.com/neovim/neovim.git /tmp/neovim --depth=1 && \
9 | cd /tmp/neovim && \
10 | make CMAKE_BUILD_TYPE=Release && \
11 | make CMAKE_INSTALL_PREFIX=/usr/local install && \
12 | strip /usr/local/bin/nvim
13 | RUN git clone https://github.com/tiagovla/.dotfiles.git /tmp/.dotfiles --depth=1
14 |
15 | FROM ubuntu:22.04
16 | ARG DEBIAN_FRONTEND=noninteractive
17 | RUN apt update && apt upgrade -y && apt install -y gcc g++ unzip wget git python3 nodejs
18 | COPY --from=builder /usr/local /usr/local/
19 | COPY --from=builder /tmp/.dotfiles/neovim/.config/nvim /root/.config/nvim/
20 |
21 | CMD ["/usr/local/bin/nvim"]
22 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/actions.json:
--------------------------------------------------------------------------------
1 | {
2 | "rewrite_academic": {
3 | "type": "chat",
4 | "opts": {
5 | "template": "Rewrite the following text more naturally in academic form keeping the latex syntax. Do not remove cref, gls and cite latex commands. Do use cref instead of ref ommiting Chapter, Figure,... \n\n{{input}}",
6 | "strategy": "replace",
7 | "params": {
8 | "model": "gpt-3.5-turbo",
9 | "temperature": 0.5,
10 | "frequency_penalty": 0.8
11 | }
12 | }
13 | },
14 | "rewrite": {
15 | "type": "chat",
16 | "opts": {
17 | "template": "Rewrite the following text.\n\n{{input}}",
18 | "strategy": "replace",
19 | "params": {
20 | "model": "gpt-3.5-turbo",
21 | "temperature": 0.5,
22 | "frequency_penalty": 0.8,
23 | "max_tokens": 2048
24 | }
25 | }
26 | },
27 | "doit": {
28 | "type": "chat",
29 | "opts": {
30 | "template": "{{input}}",
31 | "strategy": "replace",
32 | "params": {
33 | "model": "gpt-3.5-turbo",
34 | "temperature": 0.5,
35 | "frequency_penalty": 0.8,
36 | "max_tokens": 2048
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/ftplugin/cpp.lua:
--------------------------------------------------------------------------------
1 | vim.opt_local.shiftwidth = 2
2 | vim.opt_local.colorcolumn = "100"
3 | vim.o.foldmethod = "marker"
4 | vim.o.foldmarker = "/*,*/"
5 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/ftplugin/oil_preview.lua:
--------------------------------------------------------------------------------
1 | -- vim.keymap.set("n", "", function()
2 | -- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("o", true, false, true), "n", true)
3 | -- end, { silent = true })
4 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/ftplugin/python.lua:
--------------------------------------------------------------------------------
1 | -- vim.fn.jobstart({"blackd"})
2 | vim.cmd [[compiler python]]
3 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/ftplugin/tex.lua:
--------------------------------------------------------------------------------
1 | -- local call = vim.api.nvim_call_function
2 | vim.keymap.set("n", "gqq", "mzgqip`z", {})
3 | -- defer 1s and call the command below
4 | vim.defer_fn(function()
5 | vim.cmd "syntax on"
6 | end, 500)
7 |
8 | -- call("TexNewMathZone", { "E", "align", 1 })
9 | -- call("TexNewMathZone", { "F", "alignat", 1 })
10 | -- call("TexNewMathZone", { "G", "equation", 1 })
11 | -- call("TexNewMathZone", { "H", "flalign", 1 })
12 | -- call("TexNewMathZone", { "I", "gather", 1 })
13 | -- call("TexNewMathZone", { "J", "multline", 1 })
14 | -- call("TexNewMathZone", { "K", "xalignat", 1 })
15 | -- call("TexNewMathZone", { "L", "dmath", 0 })
16 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/ftplugin/tom.lua:
--------------------------------------------------------------------------------
1 | vim.opt.tabstop = 2 -- number of visual spaces per TAB
2 | vim.opt.softtabstop = 2 -- number of spaces in tab when editing
3 | vim.opt.shiftwidth = 2 -- number of spaces to use for autoindent
4 | vim.opt.expandtab = false -- expand tab to spaces so that tabs are spaces
5 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/apm.lua:
--------------------------------------------------------------------------------
1 | local counter = {}
2 | local counter_mt = { __index = counter }
3 |
4 | function counter:new()
5 | local timer = vim.loop.new_timer()
6 | local history = {}
7 | for index = 1, 60 do
8 | history[index] = 0
9 | end
10 | local state = { _accumulative = 0, history = history, timer = timer }
11 | return setmetatable(state, counter_mt)
12 | end
13 |
14 | function counter:register()
15 | for index = 59, 1, -1 do
16 | self.history[index + 1] = self.history[index]
17 | end
18 | self.history[1] = self._accumulative
19 | self._accumulative = 0
20 | end
21 |
22 | function counter:tick(value)
23 | if value == nil then
24 | self._accumulative = self._accumulative + 1
25 | else
26 | self._accumulative = value
27 | end
28 | end
29 |
30 | function counter:get_history(limit)
31 | local result = {}
32 | for index = 1, limit do
33 | result[index] = self.history[index]
34 | end
35 | return result
36 | end
37 |
38 | function counter:get_average(limit)
39 | local last = self:get_history(limit)
40 | local sum = 0
41 | for _, v in ipairs(last) do
42 | sum = sum + v
43 | end
44 | return sum * 60 / limit
45 | end
46 |
47 | function counter:start()
48 | self.timer:start(
49 | 0,
50 | 1000,
51 | vim.schedule_wrap(function()
52 | self:register()
53 | end)
54 | )
55 | end
56 |
57 | function counter:stop()
58 | self.timer:stop()
59 | end
60 |
61 | function counter:close()
62 | self.timer:close()
63 | end
64 |
65 | -- local actions = counter:new()
66 | -- local edits = counter:new()
67 | -- actions:start()
68 | -- edits:start()
69 | --
70 | -- local ns = vim.api.nvim_create_namespace "apm"
71 | -- vim.on_key(function()
72 | -- actions:tick()
73 | -- end, ns)
74 | --
75 | -- local augroup = vim.api.nvim_create_augroup("APM", {})
76 | -- vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "TextChangedP" }, {
77 | -- group = augroup,
78 | -- callback = function()
79 | -- edits:tick()
80 | -- end,
81 | -- })
82 |
83 | -- local timer = vim.loop.new_timer()
84 | -- timer:start(
85 | -- 0,
86 | -- 500,
87 | -- vim.schedule_wrap(function()
88 | -- local apm = "APM: " .. actions:get_average(2) .. " [" .. actions:get_average(60) .. "]"
89 | -- local epm = "EPM: " .. edits:get_average(2) .. " [" .. edits:get_average(60) .. "]"
90 | -- vim.pretty_print(apm .. " " .. epm)
91 | -- end)
92 | -- )
93 | --
94 | -- vim.defer_fn(function()
95 | -- actions:stop()
96 | -- actions:close()
97 | -- edits:stop()
98 | -- edits:close()
99 | -- timer:stop()
100 | -- timer:close()
101 | -- end, 20000)
102 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/async_make.lua:
--------------------------------------------------------------------------------
1 | -- local function make()
2 | -- local lines = { "" }
3 | -- local winnr = vim.fn.win_getid()
4 | -- local bufnr = vim.api.nvim_win_get_buf(winnr)
5 | --
6 | -- local makeprg = vim.api.nvim_get_option_value("makeprg", {})
7 | -- local efm = vim.api.nvim_get_option_value("errorformat", {})
8 | --
9 | -- if not makeprg then
10 | -- return
11 | -- end
12 | --
13 | -- local cmd = vim.fn.expandcmd(makeprg)
14 | -- vim.print("Running: " .. cmd)
15 | --
16 | -- local function on_event(job_id, data, event)
17 | -- if event == "stdout" or event == "stderr" then
18 | -- if data then
19 | -- vim.list_extend(lines, data)
20 | -- end
21 | -- end
22 | --
23 | -- if event == "exit" then
24 | -- vim.fn.setqflist({}, " ", {
25 | -- title = cmd,
26 | -- lines = lines,
27 | -- efm = efm,
28 | -- })
29 | -- vim.api.nvim_command "doautocmd QuickFixCmdPost"
30 | -- for i = #lines, 1, -1 do
31 | -- if lines[i] == "" then
32 | -- table.remove(lines, i)
33 | -- end
34 | -- end
35 | -- vim.print("Done: " .. cmd)
36 | -- end
37 | -- end
38 | --
39 | -- local job_id = vim.fn.jobstart(cmd, {
40 | -- on_stderr = on_event,
41 | -- on_stdout = on_event,
42 | -- on_exit = on_event,
43 | -- stdout_buffered = true,
44 | -- stderr_buffered = true,
45 | -- })
46 | -- end
47 | --
48 | -- local terminal = require("toggleterm.terminal").Terminal
49 | --
50 | -- vim.api.nvim_create_user_command("Makee", function()
51 | -- local lazygit = terminal:new {
52 | -- -- cmd = "make",
53 | -- dir = "/home/tiagovla/github/oiseau/",
54 | -- hidden = true,
55 | -- -- close_on_exit = false,
56 | -- on_stdout = function()
57 | -- print "out"
58 | -- end,
59 | -- on_stderr = function()
60 | -- print "err"
61 | -- end,
62 | -- on_exit = function()
63 | -- print "exit"
64 | -- end,
65 | -- }
66 | -- lazygit:toggle()
67 | -- lazygit:send "m"
68 | -- end, {})
69 | --
70 | -- vim.api.nvim_create_user_command("Make", make, {})
71 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/image_paste.lua:
--------------------------------------------------------------------------------
1 | local ok, _ = pcall(require, "plenary")
2 | if not ok then
3 | return
4 | end
5 |
6 | local Job = require "plenary.job"
7 | local Path = require "plenary.path"
8 |
9 | local get_targets = function()
10 | local j = Job:new {
11 | command = "xclip",
12 | args = { "-selection", "clipboard", "-t", "TARGETS", "-o" },
13 | }
14 | return vim.tbl_filter(function(x)
15 | return string.match(x, "^image/")
16 | end, j:sync())
17 | end
18 |
19 | local function get_info(targets)
20 | if not vim.tbl_contains(targets, "image/png") then
21 | return { "image/png", "png" }
22 | else
23 | return { targets[1], vim.split(targets[1], "/")[2] }
24 | end
25 | end
26 |
27 | local function save_image(folder, target, filename, extension)
28 | local image = ("%s.%s"):format(filename, extension)
29 | local path = Path:new(folder)
30 | path:mkdir { parents = true }
31 | path = path:joinpath(image)
32 | local i = 1
33 | while path:exists() do
34 | path = path:parent():joinpath(("%s_%d.%s"):format(filename, i, extension))
35 | i = i + 1
36 | end
37 | local cmd = [[xclip -selection clipboard -t %s -o > %s]]
38 | vim.fn.system(cmd:format(target, path))
39 | return path
40 | end
41 |
42 | local function image_paste(func)
43 | local targets = get_targets()
44 | if #targets == 0 then
45 | return true
46 | end
47 | local target, extension = unpack(get_info(targets))
48 | local prompt_opts = {
49 | prompt = "Image name: ",
50 | default = "image",
51 | }
52 | vim.ui.input(prompt_opts, function(filename)
53 | if not filename or #filename == 0 then
54 | return
55 | end
56 | local path = save_image("images", target, filename, extension)
57 | path = path:make_relative()
58 | if func then
59 | func(path)
60 | end
61 | end)
62 | end
63 |
64 | local function image_paste_tex()
65 | local function func(path)
66 | local cursor = vim.api.nvim_win_get_cursor(0)
67 | vim.api.nvim_buf_set_lines(0, cursor[1] - 1, cursor[1], false, {
68 | "\\begin{figure}[h]",
69 | " \\centering",
70 | " \\includegraphics[]{" .. path .. "}",
71 | "\\end{figure}",
72 | })
73 | end
74 | image_paste(func)
75 | end
76 |
77 | vim.paste = (function(overridden)
78 | return function(lines, phase)
79 | local reg = vim.fn.getreg "+"
80 | if reg == "" and vim.bo[0].ft == "tex" then
81 | image_paste_tex()
82 | else
83 | overridden(lines, phase)
84 | end
85 | end
86 | end)(vim.paste)
87 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/lsp-on-type-formatting.lua:
--------------------------------------------------------------------------------
1 | local util = require "vim.lsp.util"
2 | --
3 | -- local function handler(_, result, ctx)
4 | -- local client = vim.lsp.get_client_by_id(ctx.client_id)
5 | -- util.apply_text_edits(result, ctx.bufnr, client.offset_encoding)
6 | -- end
7 | --
8 | -- local function format_on_type()
9 | -- local client = vim.lsp.get_active_clients { name = "clangd" }
10 | -- local buf = vim.api.nvim_get_current_buf()
11 | -- if #client == 0 then
12 | -- return
13 | -- else
14 | -- client = client[1]
15 | -- end
16 | --
17 | -- local params = util.make_formatting_params {}
18 | -- local cursor = vim.api.nvim_win_get_cursor(0)
19 | -- params.position = { line = cursor[1], character = cursor[2] }
20 | -- params.ch = "\n"
21 | -- client.request("textDocument/onTypeFormatting", params, handler, buf)
22 | -- end
23 | --
24 | -- local ns = vim.api.nvim_create_namespace "onTypeFormatting"
25 | -- local function handler_on_key(key)
26 | -- local mode = vim.api.nvim_get_mode().mode
27 | -- if mode == "i" and key == "\r" then
28 | -- if vim.bo[0].filetype == "cpp" then
29 | -- vim.pretty_print(key)
30 | -- format_on_type()
31 | -- end
32 | -- end
33 | -- end
34 | --
35 | -- vim.on_key(handler_on_key, ns)
36 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/python-cc.lua:
--------------------------------------------------------------------------------
1 | -- Logic to parse pyproject.toml and set colorcolumn
2 | local function file_exists(file)
3 | local f = io.open(file, "rb")
4 | if f then
5 | f:close()
6 | end
7 | return f ~= nil
8 | end
9 |
10 | local function lines_from(file)
11 | if not file_exists(file) then
12 | return {}
13 | end
14 | local lines = {}
15 | for line in io.lines(file) do
16 | lines[#lines + 1] = line
17 | end
18 | return lines
19 | end
20 |
21 | local function get_root(bufnr, ft)
22 | local parser = vim.treesitter.get_parser(bufnr, ft, {})
23 | local tree = parser:parse()[1]
24 | return tree:root()
25 | end
26 |
27 | local function get_black_length(bufnr)
28 | local query = vim.treesitter.query.parse(
29 | "toml",
30 | [[
31 | (table
32 | (dotted_key) @dotkey (#eq? @dotkey "tool.black")
33 | (pair
34 | (bare_key) @barekey (#eq? @barekey "line-length")
35 | (integer) @length
36 | )
37 | )
38 | ]]
39 | )
40 | local root = get_root(bufnr, "toml")
41 | for id, node in query:iter_captures(root, bufnr, 0, -1) do
42 | local name = query.captures[id]
43 | if name == "length" then
44 | return vim.treesitter.get_node_text(node, bufnr)
45 | end
46 | end
47 | end
48 |
49 | vim.api.nvim_create_autocmd("LspAttach", {
50 | callback = function(args)
51 | local buffer = args.buf
52 |
53 | if vim.bo[buffer].ft ~= "python" then
54 | return
55 | end
56 | local file_name = "pyproject.toml"
57 | local tmp_buf = vim.api.nvim_create_buf(false, true)
58 | vim.api.nvim_buf_set_lines(tmp_buf, 0, -1, false, lines_from(file_name))
59 | local length = get_black_length(tmp_buf)
60 | vim.opt_local.colorcolumn = tostring(length or "88")
61 | vim.api.nvim_buf_delete(tmp_buf, {})
62 | end,
63 | })
64 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/python-env.lua:
--------------------------------------------------------------------------------
1 | local function get_std_envs()
2 | local envs = {}
3 | if vim.env.VIRTUAL_ENV then
4 | envs["VIRTUAL_ENV"] = table.concat({ vim.env.VIRTUAL_ENV, "bin", "python" }, "/")
5 | end
6 | local sys = vim.fn.exepath "python3" or vim.fn.exepath "python" or "/bin/python"
7 | envs["System"] = sys
8 | return envs
9 | end
10 |
11 | local function get_poetry_envs()
12 | local envs = {}
13 | local venv = vim.fn.trim(vim.fn.system "poetry env list --full-path")
14 | for match in string.gmatch(venv, "[%w%/%.%-]*virtualenv[%w%/%.%-]*") do
15 | local split = vim.fn.split(match, "/")
16 | envs["Poetry: " .. split[#split]] = table.concat({ match, "bin", "python" }, "/")
17 | end
18 | return envs
19 | end
20 |
21 | local function get_python_client()
22 | local pylance = vim.lsp.get_active_clients { name = "pylance" }
23 | local pyright = vim.lsp.get_active_clients { name = "pyright" }
24 | local clients = vim.tbl_extend("force", pylance, pyright)
25 | if #clients > 0 then
26 | return clients[1]
27 | end
28 | end
29 |
30 | local function env_handler()
31 | local client = get_python_client()
32 | if not client then
33 | vim.notify "No python clients found"
34 | end
35 | local options = vim.tbl_extend("force", get_std_envs(), get_poetry_envs())
36 | local settings = client.config.settings
37 | local active = settings.python.pythonPath
38 | vim.ui.select(vim.tbl_keys(options), {
39 | prompt = "Select a Python Environment:",
40 | format_item = function(item)
41 | if options[item] == active then
42 | return item .. " (Active)"
43 | end
44 | return item
45 | end,
46 | }, function(selected)
47 | if selected then
48 | settings.python.pythonPath = options[selected]
49 | client.notify("workspace/didChangeConfiguration", { settings = settings })
50 | end
51 | end)
52 | end
53 |
54 | vim.api.nvim_create_user_command("PythonEnv", env_handler, {})
55 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/tex_formatter.lua:
--------------------------------------------------------------------------------
1 | local ts_utils = require "nvim-treesitter.ts_utils"
2 |
3 | local run_formatter = function(text)
4 | local result = table.concat(text, " ")
5 | -- vim.print(result)
6 | local width = vim.opt.textwidth:get() or "80"
7 | local j = require("plenary.job"):new {
8 | command = "fmt",
9 | args = { "-w" .. width, "-u" },
10 | writer = { result },
11 | }
12 | return j:sync()
13 | end
14 |
15 | -- Get the start and end positions of the given nodes.
16 | local function get_min_max_range(nodes)
17 | local min, max = nodes[1]:start(), nodes[1]:end_()
18 | for _, node in ipairs(nodes) do
19 | local start = node:start()
20 | local end_ = node:end_()
21 | min = math.min(min, start)
22 | max = math.max(max, end_)
23 | end
24 | return min, max
25 | end
26 |
27 | -- Get the root node of the tree for a specific filetype.
28 | local function get_root_node(bufnr, ft)
29 | local parser = vim.treesitter.get_parser(bufnr, ft)
30 | local tree = parser:parse()[1]
31 | return tree:root()
32 | end
33 |
34 | -- Format the lines from `start_line` to `end_line`.
35 | local function format_lines(start_line, end_line)
36 | vim.api.nvim_win_set_cursor(0, { start_line, 0 })
37 | vim.cmd "normal! V" -- Enter visual mode
38 | vim.api.nvim_win_set_cursor(0, { end_line, 0 }) -- Select lines up to `end_line`
39 | vim.cmd "normal! gq" -- Apply formatting
40 | end
41 |
42 | -- Group nodes of specific types ("text" and "inline_formula") and format them.
43 | local function group_and_format_nodes()
44 | local groups = {}
45 | local current_group = {}
46 | local types_to_group = { "text", "inline_formula", ",", ")" }
47 | local root = get_root_node(0, "latex")
48 |
49 | -- Iterate over the root's children and group the nodes
50 | for child in root:iter_children() do
51 | if child:type() == "generic_environment" then
52 | for grandchild in child:iter_children() do
53 | if vim.tbl_contains(types_to_group, grandchild:type()) then
54 | table.insert(current_group, grandchild)
55 | elseif #current_group > 0 then
56 | table.insert(groups, current_group)
57 | current_group = {} -- Start a new group
58 | end
59 |
60 | if grandchild:type() == "section" then
61 | for grandgrandchild in grandchild:iter_children() do
62 | -- vim.print(grandgrandchild:type())
63 | if vim.tbl_contains(types_to_group, grandgrandchild:type()) then
64 | table.insert(current_group, grandgrandchild)
65 | elseif #current_group > 0 then
66 | table.insert(groups, current_group)
67 | current_group = {} -- Start a new group
68 | end
69 |
70 | if grandgrandchild:type() == "subsection" then
71 | for grandgrandgrandchild in grandgrandchild:iter_children() do
72 | -- vim.print(grandgrandgrandchild:type())
73 | if vim.tbl_contains(types_to_group, grandgrandgrandchild:type()) then
74 | table.insert(current_group, grandgrandgrandchild)
75 | elseif #current_group > 0 then
76 | table.insert(groups, current_group)
77 | current_group = {} -- Start a new group
78 | end
79 | end
80 | end
81 | end
82 | end
83 | end
84 | end
85 | end
86 | -- Insert last group if not empty
87 | if #current_group > 0 then
88 | table.insert(groups, current_group)
89 | end
90 |
91 | -- Save current cursor position and format the groups in reverse order
92 | local cursor_pos = vim.api.nvim_win_get_cursor(0)
93 | for i = #groups, 1, -1 do
94 | local group = groups[i]
95 | local min, max = get_min_max_range(group)
96 | -- vim.print { min, max }
97 | format_lines(min + 1, max + 1) -- +1 because Lua is 1-indexed
98 | end
99 | -- Restore the cursor position
100 | vim.api.nvim_win_set_cursor(0, cursor_pos)
101 | end
102 |
103 | -- Keymap for formatting the block
104 | vim.keymap.set("n", "q", group_and_format_nodes, {})
105 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/after/plugin/zoom.lua:
--------------------------------------------------------------------------------
1 | local function toggle_win_zoom()
2 | local layout = {}
3 |
4 | for _, win in ipairs(vim.api.nvim_list_wins()) do
5 | layout[win] = vim.api.nvim_win_get_config(win)
6 | end
7 |
8 | local ok, value = pcall(vim.api.nvim_win_get_var, 0, "zoomed_win")
9 |
10 | if ok and type(value) == "table" then
11 | for win, config in pairs(value) do
12 | if vim.api.nvim_win_is_valid(win) then
13 | vim.api.nvim_win_set_config(win, config)
14 | end
15 | end
16 | vim.api.nvim_win_set_var(0, "zoomed_win", nil)
17 | else
18 | local old_config = vim.api.nvim_win_get_config(0)
19 | local config = vim.deepcopy(old_config)
20 | config.width = vim.api.nvim_get_option "columns"
21 | config.height = vim.api.nvim_get_option "lines"
22 | if old_config.height ~= config.height or old_config.width ~= config.width then
23 | vim.api.nvim_win_set_var(0, "zoomed_win", layout)
24 | vim.api.nvim_win_set_config(0, config)
25 | end
26 | end
27 | end
28 |
29 | vim.keymap.set("n", "z", toggle_win_zoom, { desc = "Zoom in window", noremap = true, silent = true })
30 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/compiler/python.vim:
--------------------------------------------------------------------------------
1 | " Compiler: Python
2 |
3 | if exists("current_compiler")
4 | finish
5 | endif
6 |
7 | let current_compiler = "python"
8 |
9 | if exists(":CompilerSet") != 2 " older Vim always used :setlocal
10 | command -nargs=* CompilerSet setlocal
11 | endif
12 |
13 | " Disable Python warnings
14 | if !exists('$PYTHONWARNINGS')
15 | let $PYTHONWARNINGS="ignore"
16 | endif
17 |
18 | " Enhanced error formatting for Python (pytest, Flake8, etc.)
19 | CompilerSet efm =%E%f:%l:\ could\ not\ compile,
20 | CompilerSet efm +=%-Z%p^,
21 | CompilerSet efm +=%A%f:%l:%c:\ %t%n\ %m,
22 | CompilerSet efm +=%A%f:%l:\ %t%n\ %m,
23 |
24 | " Capture traceback in error output
25 | CompilerSet efm +=%+GTraceback%.%#,
26 |
27 | " Capture Python error messages starting with 'File', including line number and message
28 | CompilerSet efm +=%E\ \ File\ \"%f\"\\,\ line\ %l\\,%m%\\C,
29 | CompilerSet efm +=%E\ \ File\ \"%f\"\\,\ line\ %l%\\C,
30 |
31 | " Handle continuation lines, properly highlight the column where the error occurs
32 | CompilerSet efm +=%C%p^,
33 |
34 | " Capture indented error information, useful for deeper Python errors
35 | CompilerSet efm +=%+C\ \ \ \ %.%#,
36 | CompilerSet efm +=%+C\ \ %.%#,
37 |
38 | " Catch Python-specific warnings or general message at the end of an error
39 | CompilerSet efm +=%Z%\\S%\\&%m,
40 |
41 | " Ignore unnecessary lines from Python traceback
42 | CompilerSet efm +=%-G%.%#
43 |
44 | " Improved handling for pytest output (if used)
45 | CompilerSet efm +=%A%f:%l:\ %m,
46 |
47 | " Default command for running the Python code
48 | if filereadable("Makefile")
49 | CompilerSet makeprg=make
50 | else
51 | CompilerSet makeprg=python3
52 | endif
53 |
54 | " vim:foldmethod=marker:foldlevel=0
55 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/init.lua:
--------------------------------------------------------------------------------
1 | -- vim.lsp.set_log_level "debug"
2 | vim.deprecate = function() end -- YOLO
3 | vim.loader.enable()
4 | require "tiagovla"
5 |
6 | require "plugins"
7 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/init.lua:
--------------------------------------------------------------------------------
1 | local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
2 | if not vim.loop.fs_stat(lazypath) then
3 | vim.fn.system {
4 | "git",
5 | "clone",
6 | "--filter=blob:none",
7 | "--single-branch",
8 | "https://github.com/folke/lazy.nvim.git",
9 | lazypath,
10 | }
11 | end
12 | vim.opt.runtimepath:prepend(lazypath)
13 |
14 | require("lazy").setup("plugins.modules", {
15 | defaults = { lazy = true },
16 | install = { colorscheme = { "tokyodark" } },
17 | change_detection = {
18 | enabled = true,
19 | notify = false,
20 | },
21 | ui = { border = "rounded" },
22 | checker = { enabled = false },
23 | performance = {
24 | rtp = {
25 | disabled_plugins = {
26 | "gzip",
27 | "matchit",
28 | "matchparen",
29 | "netrwPlugin",
30 | "tarPlugin",
31 | "tohtml",
32 | "tutor",
33 | "zipPlugin",
34 | },
35 | },
36 | },
37 | git = { timeout = 600 },
38 | debug = false,
39 | dev = {
40 | path = "~/github",
41 | pattern = { "tiagovla" },
42 | fallback = true,
43 | },
44 | })
45 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules.lua:
--------------------------------------------------------------------------------
1 | return {
2 | {
3 | "nvim-tree/nvim-web-devicons",
4 | config = function()
5 | require("nvim-web-devicons").setup { default = true }
6 | end,
7 | },
8 | { "famiu/bufdelete.nvim", event = "VeryLazy" },
9 | { "krady21/compiler-explorer.nvim", event = "VeryLazy" },
10 | { "Almo7aya/openingh.nvim", event = "VeryLazy" },
11 | {
12 | "tiagovla/scope.nvim",
13 | event = "BufRead",
14 | config = function()
15 | require("scope").setup { restore_state = true }
16 | vim.keymap.set({ "n", "o", "x" }, "T", function()
17 | local old_tab = vim.api.nvim_get_current_tabpage()
18 | local buf = vim.api.nvim_get_current_buf()
19 | vim.cmd [[execute "normal! \T"]]
20 | local new_tab = vim.api.nvim_get_current_tabpage()
21 | if old_tab ~= new_tab then
22 | local cache = require("scope.core").cache
23 | cache[old_tab] = vim.tbl_filter(function(e)
24 | return e ~= buf
25 | end, cache[old_tab])
26 | end
27 | end, { desc = "move into new tab", remap = true })
28 | end,
29 | dev = true,
30 | },
31 | {
32 | "tiagovla/buffercd.nvim",
33 | event = "BufRead",
34 | config = function()
35 | require("buffercd").setup {}
36 | end,
37 | },
38 | { "tiagovla/tex-conceal.vim", ft = "tex" },
39 | {
40 | "tiagovla/projet.nvim",
41 | config = function()
42 | require("projet").setup {}
43 | vim.keymap.set("n", "kk", function()
44 | require("projet").prompt()
45 | end, { desc = "Project files" })
46 | vim.keymap.set("n", "kl", function()
47 | require("projet").toggle_editor()
48 | end, { desc = "Project files" })
49 | end,
50 | dev = true,
51 | event = "VeryLazy",
52 | },
53 | {
54 | "nvim-treesitter/nvim-treesitter-context",
55 | config = function()
56 | require("treesitter-context").setup {
57 | enable = true,
58 | max_lines = 0,
59 | min_window_height = 0,
60 | line_numbers = true,
61 | multiline_threshold = 20,
62 | trim_scope = "outer",
63 | mode = "cursor",
64 | separator = nil,
65 | zindex = 20,
66 | on_attach = nil,
67 | }
68 | end,
69 | },
70 | {
71 | "OXY2DEV/markview.nvim",
72 | lazy = false,
73 | ft = "markdown",
74 | dependencies = {
75 | "nvim-treesitter/nvim-treesitter",
76 | "nvim-tree/nvim-web-devicons",
77 | },
78 | },
79 | {
80 | "windwp/nvim-ts-autotag",
81 | lazy = false,
82 | config = function()
83 | require("nvim-ts-autotag").setup {
84 | opts = {
85 | enable_close = true,
86 | enable_rename = true,
87 | enable_close_on_slash = false,
88 | },
89 | per_filetype = {
90 | ["html"] = {
91 | enable_close = false,
92 | },
93 | },
94 | }
95 | end,
96 | },
97 | {
98 | "lowitea/aw-watcher.nvim",
99 | lazy = false,
100 | opts = {
101 | aw_server = {
102 | host = "127.0.0.1",
103 | port = 5600,
104 | },
105 | },
106 | },
107 |
108 | {
109 | "CopilotC-Nvim/CopilotChat.nvim",
110 | lazy = false,
111 | dependencies = {
112 | { "zbirenbaum/copilot.lua" },
113 | { "nvim-lua/plenary.nvim", branch = "master" },
114 | },
115 | build = "make tiktoken",
116 | opts = {},
117 | },
118 | {
119 | "folke/snacks.nvim",
120 | priority = 1000,
121 | lazy = false,
122 | opts = {
123 | gitbrowse = { enabled = true },
124 | bigfile = { enabled = true },
125 | -- notifier = { enabled = true },
126 | quickfile = { enabled = true },
127 | words = { enabled = true },
128 | },
129 | },
130 | {
131 | "yioneko/nvim-type-fmt",
132 | lazy = false,
133 | config = function()
134 | require("type-fmt").setup {}
135 | end,
136 | },
137 |
138 | {
139 | "mfussenegger/nvim-lint",
140 | lazy = false,
141 |
142 | config = function()
143 | local lint = require "lint"
144 | lint.linters_by_ft = {
145 | ["cpp"] = { "cppcheck" },
146 | ["hpp"] = { "cppcheck" },
147 | }
148 | lint.linters.cppcheck.args[#lint.linters.cppcheck.args + 1] = "--check-level=exhaustive"
149 | vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter" }, {
150 | callback = function()
151 | require("lint").try_lint()
152 | end,
153 | })
154 | end,
155 | },
156 | }
157 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/barbecue.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "utilyre/barbecue.nvim",
3 | name = "barbecue",
4 | version = "*",
5 | dependencies = {
6 | "SmiteshP/nvim-navic",
7 | "nvim-tree/nvim-web-devicons",
8 | },
9 | opts = {},
10 | lazy = false,
11 | }
12 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/bufferline.lua:
--------------------------------------------------------------------------------
1 | local function get_harpoon_mark_from_id(id)
2 | local harpoon = require "harpoon"
3 | local Path = require "plenary.path"
4 | local list = harpoon:list()
5 |
6 | local buf_name = vim.api.nvim_buf_get_name(id)
7 | local root_dir = list.config.get_root_dir()
8 | local n_path = Path:new(buf_name):make_relative(root_dir)
9 | local _, idx = list:get_by_value(n_path)
10 | return idx
11 | end
12 |
13 | return {
14 | "akinsho/nvim-bufferline.lua",
15 | lazy = false,
16 | init = function()
17 | vim.keymap.set("n", "", "BufferLineCycleNext")
18 | vim.keymap.set("n", "", "BufferLineCyclePrev")
19 | end,
20 | opts = {
21 | options = {
22 | view = "multiwindow",
23 | numbers = function(opts)
24 | return get_harpoon_mark_from_id(opts.id)
25 | end,
26 | modified_icon = "●",
27 | max_prefix_length = 5,
28 | tab_size = 18,
29 | diagnostics = "nvim_lsp",
30 | separator_style = { "|", "" },
31 | offsets = {
32 | {
33 | filetype = "NvimTree",
34 | text = "File Explorer",
35 | text_align = "center",
36 | },
37 | },
38 | sort_by = function(buffer_a, buffer_b)
39 | local function get_local_mark(id)
40 | return get_harpoon_mark_from_id(id) or 999999
41 | end
42 | return get_local_mark(buffer_a.id) < get_local_mark(buffer_b.id)
43 | end,
44 | },
45 | },
46 | }
47 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/chatgpt.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "jackMort/ChatGPT.nvim",
3 | event = "VeryLazy",
4 | config = function()
5 | require("chatgpt").setup {
6 | actions_paths = { vim.fs.joinpath(vim.fn.stdpath "config", "actions.json") },
7 | }
8 | end,
9 | init = function()
10 | vim.keymap.set("n", "cr", "vip:ChatGPTRun rewrite", { desc = "chatGPT rewrite" })
11 | vim.keymap.set("n", "cR", "vip:ChatGPTRun rewrite_academic", { desc = "chatGPT rewrite academic" })
12 | vim.keymap.set("v", "cR", ":ChatGPTRun rewrite", { desc = "chatGPT rewrite" })
13 | vim.keymap.set("v", "cr", ":ChatGPTRun rewrite_academic", { desc = "chatGPT rewrite academic" })
14 | vim.keymap.set("v", "cd", ":ChatGPTRun doit", { desc = "chatGPT do it" })
15 | end,
16 | dependencies = {
17 | "MunifTanjim/nui.nvim",
18 | "nvim-lua/plenary.nvim",
19 | "nvim-telescope/telescope.nvim",
20 | },
21 | }
22 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/cmp.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | {
3 | "saghen/blink.cmp",
4 | version = "v1.3.1",
5 | dependencies = {
6 | { "rafamadriz/friendly-snippets" },
7 | { "hrsh7th/cmp-nvim-lua" },
8 | { "kdheepak/cmp-latex-symbols" },
9 | { "onsails/lspkind-nvim" },
10 | {
11 | "saghen/blink.compat",
12 | version = "v2.5.0",
13 | lazy = true,
14 | opts = {
15 | impersonate_nvim_cmp = true,
16 | debug = true,
17 | },
18 | },
19 | {
20 | "tiagovla/zotex.nvim",
21 | config = function()
22 | require("zotex").setup {}
23 | end,
24 | dependencies = { "kkharji/sqlite.lua" },
25 | dev = true,
26 | },
27 | },
28 | opts = {
29 | enabled = function()
30 | return not vim.list_contains({ "DressingInput" }, vim.bo.filetype)
31 | and vim.bo.buftype ~= "prompt"
32 | and vim.b.completion ~= false
33 | end,
34 | snippets = {
35 | preset = "luasnip",
36 | expand = function(snippet)
37 | require("luasnip").lsp_expand(snippet)
38 | end,
39 | active = function(filter)
40 | if filter and filter.direction then
41 | return require("luasnip").jumpable(filter.direction)
42 | end
43 | return require("luasnip").in_snippet()
44 | end,
45 | jump = function(direction)
46 | require("luasnip").jump(direction)
47 | end,
48 | },
49 | cmdline = {
50 | keymap = {
51 | preset = "enter",
52 | [""] = { "show_and_insert", "select_next" },
53 | [""] = { "show_and_insert", "select_prev" },
54 | [""] = { "accept_and_enter", "fallback" },
55 | },
56 | sources = function()
57 | return vim.fn.getcmdtype() == ":" and { "cmdline" } or {}
58 | end,
59 | completion = {
60 | menu = {
61 | auto_show = function(ctx)
62 | return vim.fn.getcmdtype() == ":"
63 | end,
64 | },
65 | },
66 | },
67 | appearance = {
68 | use_nvim_cmp_as_default = true,
69 | nerd_font_variant = "mono",
70 | },
71 | sources = {
72 | default = { "lsp", "path", "snippets", "buffer", "latex_symbols", "zotex", "nvim_lua" },
73 | providers = {
74 | nvim_lua = {
75 | name = "nvim_lua",
76 | module = "blink.compat.source",
77 | score_offset = -3,
78 | opts = {},
79 | },
80 | latex_symbols = {
81 | name = "latex_symbols",
82 | module = "blink.compat.source",
83 | score_offset = -3,
84 | opts = {},
85 | },
86 | zotex = {
87 | name = "zotex",
88 | module = "blink.compat.source",
89 | score_offset = -3,
90 | opts = {},
91 | },
92 | },
93 | min_keyword_length = function(ctx)
94 | return ctx.trigger.kind == "trigger_character" and 0 or 3
95 | end,
96 | },
97 | completion = {
98 | accept = {
99 | auto_brackets = {
100 | enabled = true,
101 | override_brackets_for_filetypes = {
102 | tex = { "{", "}" },
103 | },
104 | },
105 | },
106 | menu = {
107 | min_width = 30,
108 | scrolloff = 2,
109 | border = { "┌", "─", "┐", "│", "┘", "─", "└", "│" },
110 | winhighlight = "Normal:Normal,FloatBorder:VertSplit,CursorLine:FocusedSymbol,Search:None",
111 | draw = {
112 | columns = { { "kind_icon" }, { "label", "label_description", gap = 1 }, { "source_icon" } },
113 | components = {
114 | source_icon = {
115 | ellipsis = false,
116 | text = function(ctx)
117 | if ctx.item.data and ctx.item.data.citation then
118 | return "[ZoTeX]"
119 | end
120 | local map = {
121 | luasnip = "[SNIP]",
122 | buffer = "[BUF]",
123 | lsp = "[LSP]",
124 | nvim_lua = "[LUA]",
125 | path = "[PATH]",
126 | latex_symbols = "[LaTeX]",
127 | zotex = "[ZoTeX]",
128 | snippets = "[SNIP]",
129 | }
130 | return map[ctx.item.source_id] or ctx.item.source_id
131 | end,
132 | highlight = "BlinkCmpSource",
133 | },
134 | },
135 | },
136 | },
137 | },
138 | },
139 | opts_extend = { "sources.default" },
140 | },
141 | }
142 |
143 | return M
144 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/colorizer.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "norcalli/nvim-colorizer.lua",
3 | ft = { "html", "css", "sass", "vim", "lua", "javascript", "typescript" },
4 | config = function()
5 | require("colorizer").setup({ "*" }, {
6 | RGB = true,
7 | RRGGBB = true,
8 | RRGGBBAA = true,
9 | rgb_fn = true,
10 | hsl_fn = true,
11 | css = true,
12 | css_fn = true,
13 | })
14 | end,
15 | }
16 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/comment.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "numToStr/Comment.nvim",
3 | event = "VeryLazy",
4 | config = true,
5 | }
6 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/copilot.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "zbirenbaum/copilot.lua",
3 | event = "VeryLazy",
4 | init = function()
5 | vim.api.nvim_create_user_command("ToggleCopilot", function()
6 | require("copilot.suggestion").toggle_auto_trigger()
7 | end, {})
8 | end,
9 | opts = {
10 | panel = {
11 | keymap = {
12 | jump_next = "",
13 | jump_prev = "",
14 | accept = "",
15 | refresh = "r",
16 | open = "",
17 | },
18 | },
19 | suggestion = {
20 | enable = true,
21 | auto_trigger = true,
22 | keymap = {
23 | next = "",
24 | prev = "",
25 | accept = "",
26 | dismiss = "",
27 | },
28 | },
29 | },
30 | }
31 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/dap.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "mfussenegger/nvim-dap",
3 | event = "VeryLazy",
4 | dependencies = {
5 | { "theHamsta/nvim-dap-virtual-text" },
6 | { "rcarriga/nvim-dap-ui" },
7 | },
8 | }
9 |
10 | function M.init()
11 | local keys = {
12 | ["db"] = { "toggle_breakpoint", "Toggle breakpoint" },
13 | ["dB"] = { "step_back", "Step back" },
14 | ["dc"] = { "continue", "Continue" },
15 | ["dC"] = { "run_to_cursor", "Run to cursor" },
16 | ["dd"] = { "disconnect", "Disconnect" },
17 | ["dS"] = { "session", "Session" },
18 | ["di"] = { "step_into", "Setep into" },
19 | ["do"] = { "step_over", "Step over" },
20 | ["du"] = { "step_out", "Step out" },
21 | ["dp"] = { "pause.toggle", "Pause toggle" },
22 | -- ["dr"] = { "repl.open", "REPL toggle" },
23 | ["ds"] = { "continue", "Continue" },
24 | ["dq"] = { "close", "Close" },
25 | }
26 | for k, v in pairs(keys) do
27 | vim.keymap.set("n", "" .. k, function()
28 | return require("dap")[v[1]]()
29 | end, { desc = v[2] })
30 | end
31 | vim.keymap.set("n", "dr", function()
32 | return require("dap").repl.toggle()
33 | end, { desc = "REPL toggle" })
34 | end
35 |
36 | local function config_dap()
37 | local dap = require "dap"
38 | dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
39 |
40 | dap.adapters.python = {
41 | type = "executable",
42 | command = "debugpy-adapter",
43 | }
44 |
45 | dap.adapters.cppdbg = {
46 | id = "cppdbg",
47 | type = "executable",
48 | command = "OpenDebugAD7",
49 | }
50 |
51 | local get_python_path = function()
52 | local venv_path = os.getenv "VIRTUAL_ENV"
53 | if venv_path then
54 | return venv_path .. "/bin/python"
55 | end
56 | return nil
57 | end
58 |
59 | dap.configurations.cpp = {
60 | {
61 | name = "Launch file",
62 | type = "cppdbg",
63 | request = "launch",
64 | program = function()
65 | return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
66 | end,
67 | cwd = "${workspaceFolder}",
68 | stopAtEntry = true,
69 | },
70 | }
71 |
72 | dap.configurations.python = {
73 | {
74 | type = "python",
75 | request = "launch",
76 | name = "Launch file",
77 | program = "${file}",
78 | pythonPath = function()
79 | local cwd = vim.fn.getcwd()
80 | if vim.fn.glob(cwd .. "/poetry.lock") then
81 | local venv = vim.fn.trim(vim.fn.system "poetry env info -p")
82 | return venv .. "/bin" .. "/python"
83 | end
84 | if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
85 | return cwd .. "/venv/bin/python"
86 | elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
87 | return cwd .. "/.venv/bin/python"
88 | elseif vim.fn.exists "$VIRTUAL_ENV" then
89 | return get_python_path()
90 | else
91 | return "/usr/bin/python"
92 | end
93 | end,
94 | },
95 | }
96 | end
97 |
98 | local function config_dap_ui()
99 | local dap = require "dap"
100 | local dapui = require "dapui"
101 | dapui.setup {
102 | icons = { expanded = "▾", collapsed = "▸" },
103 | mappings = {
104 | -- Use a table to apply multiple mappings
105 | expand = { "", "<2-LeftMouse>" },
106 | open = "o",
107 | remove = "d",
108 | edit = "e",
109 | repl = "r",
110 | toggle = "t",
111 | },
112 | layouts = {
113 | {
114 | elements = {
115 | "scopes",
116 | "breakpoints",
117 | "stacks",
118 | "watches",
119 | },
120 | size = 40,
121 | position = "right",
122 | },
123 | {
124 | elements = {
125 | "repl",
126 | },
127 | size = 10,
128 | position = "bottom",
129 | },
130 | },
131 | floating = {
132 | max_height = nil,
133 | max_width = nil,
134 | border = "single",
135 | mappings = {
136 | close = { "q", "" },
137 | },
138 | },
139 | windows = { indent = 1 },
140 | }
141 |
142 | -- vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" })
143 |
144 | dap.listeners.after.event_initialized["dapui_config"] = function()
145 | dapui.open()
146 | vim.keymap.set("v", "K", [[lua require("dapui").eval()]], { buffer = 0 })
147 | vim.keymap.set("n", "K", [[lua require("dapui").eval()]], { buffer = 0 })
148 | end
149 | dap.listeners.before.event_terminated["dapui_config"] = function()
150 | dapui.close()
151 | end
152 | dap.listeners.before.event_exited["dapui_config"] = function()
153 | dapui.close()
154 | end
155 | end
156 |
157 | function M.config()
158 | config_dap()
159 | config_dap_ui()
160 | require("nvim-dap-virtual-text").setup()
161 | end
162 |
163 | return M
164 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/dressing.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "stevearc/dressing.nvim",
3 | event = "VeryLazy",
4 | opts = {
5 | input = {
6 | win_options = {
7 | winblend = 0,
8 | },
9 | },
10 | select = {
11 | backend = { "fzf_lua", "fzf", "builtin", "nui" },
12 | nui = {
13 | win_options = {
14 | winblend = 0,
15 | },
16 | },
17 | builtin = {
18 | win_options = {
19 | winblend = 0,
20 | },
21 | },
22 | },
23 | },
24 | }
25 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/gitsigns.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "lewis6991/gitsigns.nvim",
3 | event = "VeryLazy",
4 | dependencies = { "nvim-lua/plenary.nvim" },
5 | }
6 |
7 | function M.config()
8 | require("gitsigns").setup {
9 | signs = {
10 | add = { text = "│" },
11 | change = { text = "│" },
12 | delete = { text = "│" },
13 | topdelete = { text = "-" },
14 | changedelete = { text = "~" },
15 | untracked = { text = "│" },
16 | },
17 | on_attach = function(bufnr)
18 | local gs = package.loaded.gitsigns
19 |
20 | local function w(func)
21 | return function()
22 | func()
23 | vim.defer_fn(function()
24 | vim.cmd "NvimTreeRefresh"
25 | end, 50)
26 | end
27 | end
28 |
29 | local function map(mode, l, r, opts)
30 | opts = opts or {}
31 | opts.buffer = bufnr
32 | vim.keymap.set(mode, l, w(r), opts)
33 | end
34 |
35 | map("n", "]c", gs.next_hunk, { desc = "Next Hunk" })
36 | map("n", "[c", gs.prev_hunk, { desc = "Prev Hunk" })
37 | map("n", "hs", gs.stage_hunk, { desc = "Stage hunk" })
38 | map("n", "hr", gs.reset_hunk, { desc = "Reset hunk" })
39 | map("n", "hS", gs.stage_buffer, { desc = "Stage buffer" })
40 | map("n", "hu", gs.undo_stage_hunk, { desc = "Undo stage hunk" })
41 | map("n", "hR", gs.reset_buffer, { desc = "Reset buffer" })
42 | map("n", "hp", gs.preview_hunk, { desc = "Preview hunk" })
43 | map("n", "hb", gs.toggle_current_line_blame, { desc = "Toggle current line blame" })
44 | map("n", "hd", gs.diffthis, { desc = "Diff this" })
45 | map({ "o", "x" }, "ih", gs.select_hunk, { desc = "Select hunk" })
46 | end,
47 | watch_gitdir = { interval = 1000 },
48 | sign_priority = 6,
49 | update_debounce = 200,
50 | status_formatter = nil,
51 | }
52 | end
53 |
54 | return M
55 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/harpoon.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "ThePrimeagen/harpoon",
3 | lazy = false,
4 | branch = "harpoon2",
5 | dependencies = { "nvim-lua/plenary.nvim" },
6 | config = function()
7 | local opts = { noremap = true, silent = true }
8 | local harpoon = require "harpoon"
9 | harpoon:setup()
10 | vim.keymap.set("n", "", function()
11 | harpoon.ui:toggle_quick_menu(harpoon:list())
12 | end, opts)
13 |
14 | for i = 1, 9 do
15 | vim.keymap.set("n", "" .. i, function()
16 | harpoon:list():select(i)
17 | end, { desc = "Harpoon " .. i .. " file" })
18 | end
19 | vim.keymap.set("n", "", function()
20 | harpoon:list():add()
21 | vim.notify "marked file"
22 | end, opts)
23 |
24 | vim.api.nvim_create_autocmd("FileType", {
25 | pattern = "harpoon",
26 | callback = function()
27 | for i = 1, 9 do
28 | vim.keymap.set("n", tostring(i), function()
29 | harpoon:list():select(i)
30 | end, { buffer = true })
31 | end
32 | end,
33 | })
34 | end,
35 | }
36 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/image.lua:
--------------------------------------------------------------------------------
1 | return {} -- disable it
2 | or {
3 | "3rd/image.nvim",
4 | ft = "markdown",
5 | init = function()
6 | package.path = package.path .. ";" .. vim.fn.expand "$HOME" .. "/.luarocks/share/lua/5.1/?/init.lua;"
7 | package.path = package.path .. ";" .. vim.fn.expand "$HOME" .. "/.luarocks/share/lua/5.1/?.lua;"
8 | end,
9 | config = function()
10 | require("image").setup {
11 | backend = "kitty",
12 | integrations = {
13 | markdown = {
14 | enabled = true,
15 | clear_in_insert_mode = false,
16 | download_remote_images = true,
17 | only_render_image_at_cursor = false,
18 | filetypes = { "markdown", "vimwiki" },
19 | },
20 | neorg = {
21 | enabled = true,
22 | clear_in_insert_mode = false,
23 | download_remote_images = true,
24 | only_render_image_at_cursor = false,
25 | filetypes = { "norg" },
26 | },
27 | },
28 | max_width = nil,
29 | max_height = nil,
30 | max_width_window_percentage = nil,
31 | max_height_window_percentage = 50,
32 | window_overlap_clear_enabled = false, -- toggles images when windows are overlapped
33 | window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" },
34 | editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus
35 | tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off)
36 | hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" }, -- render image files as images when opened
37 | }
38 | end,
39 | enable = false,
40 | }
41 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/local-highlight.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "tzachar/local-highlight.nvim",
3 | event = "VeryLazy",
4 | config = function()
5 | require("local-highlight").setup {
6 | file_types = { "python", "cpp", "lua" },
7 | hlgroup = "Visual",
8 | }
9 | end,
10 | }
11 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/custom/init.lua:
--------------------------------------------------------------------------------
1 | require "plugins.modules.lsp.custom.pylance"
2 | require "plugins.modules.lsp.custom.wolfram_ls"
3 |
4 | local registry = {}
5 | registry["pylance"] = "plugins.modules.lsp.custom.pylance"
6 |
7 | return registry
8 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/custom/null-ls.lua:
--------------------------------------------------------------------------------
1 | local h = require "null-ls.helpers"
2 | local methods = require "null-ls.methods"
3 |
4 | local FORMATTING = methods.internal.FORMATTING
5 |
6 | local custom = { format = {} }
7 | --
8 | custom.format["tex-fmt"] = h.make_builtin {
9 | name = "tex-fmt",
10 | method = { FORMATTING },
11 | filetypes = { "tex" },
12 | generator_opts = {
13 | command = "tex-fmt",
14 | args = { "--stdin", "--tabsize", "4" },
15 | to_stdin = true,
16 | },
17 | factory = h.formatter_factory,
18 | }
19 |
20 | return custom
21 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/custom/wolfram_ls.lua:
--------------------------------------------------------------------------------
1 | local configs = require "lspconfig.configs"
2 | local util = require "lspconfig.util"
3 |
4 | if not configs["wolfram_ls"] then
5 | configs["wolfram_ls"] = {
6 | default_config = {
7 | filetypes = { "wolfram" },
8 | root_dir = util.find_git_ancestor,
9 | cmd = {
10 | "WolframKernel",
11 | "-noinit",
12 | "-noprompt",
13 | "-nopaclet",
14 | "-noicon",
15 | "-nostartuppaclets",
16 | "-run",
17 | [[ Needs["LSPServer`"];LSPServer`StartServer[] ]],
18 | },
19 | single_file_support = true,
20 | settings = {
21 | wolfram = { implicitTokens = {}, semanticTokens = true },
22 | },
23 | },
24 | }
25 | end
26 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/handlers.lua:
--------------------------------------------------------------------------------
1 | vim.lsp.handlers["window/logMessage"] = function(_, content, _)
2 | if content.type == 3 then
3 | if content.message:find "pythonPath" then
4 | vim.notify(content.message)
5 | end
6 | end
7 | end
8 | --
9 | -- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
10 | -- border = "single",
11 | -- })
12 | --
13 | -- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
14 | -- border = "single",
15 | -- })
16 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/init.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "neovim/nvim-lspconfig",
3 | dependencies = {
4 | { "nvimtools/none-ls.nvim" },
5 | { "williamboman/mason.nvim" },
6 | { "microsoft/python-type-stubs" },
7 | { "barreiroleo/ltex_extra.nvim" },
8 | },
9 | event = { "BufReadPre", "BufNewFile" },
10 | cmd = "Mason",
11 | }
12 | function M.config()
13 | require "plugins.modules.lsp.custom"
14 | require "plugins.modules.lsp.settings"
15 | require "plugins.modules.lsp.mappings"
16 | require "plugins.modules.lsp.handlers"
17 | require "plugins.modules.lsp.null-ls"
18 | require "plugins.modules.lsp.servers"
19 | end
20 |
21 | return M
22 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/mappings.lua:
--------------------------------------------------------------------------------
1 | local mappings = {}
2 |
3 | vim.api.nvim_create_user_command("ToggleFormatting", function()
4 | if vim.g.format_on_save then
5 | vim.g.format_on_save = false
6 | vim.notify "Formatting on save disabled"
7 | else
8 | vim.g.format_on_save = true
9 | vim.notify "Formatting on save enabled"
10 | end
11 | end, {})
12 |
13 | mappings.texlab = function()
14 | vim.keymap.set("n", "lb", "TexlabBuild", { buffer = 0, desc = "Build document" })
15 | vim.keymap.set("n", "lv", function()
16 | vim.cmd.TexlabForward()
17 | vim.cmd [[!sleep 0.3 && bspc node last -f]]
18 | end, { buffer = 0, desc = "Forward view" })
19 | end
20 |
21 | mappings.clangd = function()
22 | vim.keymap.set("n", "", "ClangdSwitchSourceHeader", { buffer = 0, desc = "Build document" })
23 | end
24 |
25 | function mappings.setup(client_name, buffer)
26 | vim.keymap.set("n", "o", function()
27 | vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
28 | end, { buffer = buffer, desc = "Toggle typehints" })
29 | vim.keymap.set("n", "ga", vim.lsp.buf.code_action, { buffer = buffer, desc = "Code action" })
30 | vim.keymap.set("v", "ga", vim.lsp.buf.code_action, { buffer = buffer, desc = "Code action (range)" })
31 | vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = buffer, desc = "Go to declaration" })
32 | vim.keymap.set("n", "gd", function()
33 | local api = require "trouble.api"
34 | if api.is_open() then
35 | api.close()
36 | end
37 | vim.cmd.Trouble "lsp_definitions focus=true auto_close=true"
38 | end, { buffer = buffer, desc = "Go to definition" })
39 | -- vim.keymap.set("n", "gd", function()
40 | -- require("snacks").picker.lsp_definitions {}
41 | -- end, { buffer = buffer, desc = "Go to definition" })
42 | vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = buffer, desc = "Go to inplementation" })
43 | vim.keymap.set("n", "gr", vim.lsp.buf.rename, { buffer = buffer, desc = "Rename" })
44 | vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = buffer, desc = "Type definition" })
45 | vim.keymap.set(
46 | "n",
47 | "lq",
48 | vim.diagnostic.setloclist,
49 | { buffer = buffer, desc = "Diagnostics in local list" }
50 | )
51 | vim.keymap.set("n", "lQ", vim.diagnostic.setqflist, { buffer = buffer, desc = "Diagnostics in quick list" })
52 | vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = buffer, desc = "Hover" })
53 | vim.keymap.set("n", "gR", vim.lsp.buf.references, { buffer = buffer, desc = "References" })
54 | vim.keymap.set("n", "gk", vim.lsp.buf.signature_help, { buffer = buffer, desc = "Signature help" })
55 | vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { buffer = buffer, desc = "Next diagnostic" })
56 | vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { buffer = buffer, desc = "Prev diagnostic" })
57 | vim.keymap.set("n", "ge", vim.diagnostic.open_float, { buffer = buffer, desc = "Open float diagnostics" })
58 | vim.keymap.set({ "n", "v" }, "f", function()
59 | vim.lsp.buf.format {
60 | timeout_ms = 5000,
61 | -- filter = function(c)
62 | -- return c.name == "null-ls"
63 | -- end,
64 | }
65 | end, { buffer = 0, desc = "Format buffer" })
66 |
67 | if mappings[client_name] then
68 | mappings[client_name]()
69 | end
70 | end
71 |
72 | vim.api.nvim_create_autocmd("LspAttach", {
73 | callback = function(args)
74 | local buffer = args.buf
75 | local client_name = vim.lsp.get_client_by_id(args.data.client_id)["name"]
76 | mappings.setup(client_name, buffer)
77 | end,
78 | })
79 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/null-ls.lua:
--------------------------------------------------------------------------------
1 | local ok, null = pcall(require, "null-ls")
2 | if not ok then
3 | return
4 | end
5 |
6 | local custom = require "plugins.modules.lsp.custom.null-ls"
7 |
8 | local format = null.builtins.formatting
9 | local actions = null.builtins.code_actions
10 | local diag = null.builtins.diagnostics
11 | local completion = null.builtins.completion
12 |
13 | null.setup {
14 | sources = {
15 | -- format.blackd.with { config = { line_length = 88 } },
16 | -- diag.textidote.with {
17 | -- args = {
18 | -- "--read-all",
19 | -- "--output",
20 | -- "singleline",
21 | -- "--no-color",
22 | -- "$FILENAME",
23 | -- },
24 | -- timeout = 20000,
25 | -- },
26 | format.black.with {
27 | extra_args = function(_)
28 | return {
29 | "--fast",
30 | "--quiet",
31 | }
32 | end,
33 | },
34 | actions.gitsigns,
35 | format.bibclean,
36 | -- diag.shellcheck,
37 | diag.hadolint,
38 | -- diag.cppcheck,
39 | format.stylua,
40 | format.yamlfmt,
41 | format.clang_format,
42 | -- format.prettier.with {
43 | -- extra_args = function(_)
44 | -- return vim.bo[0].ft == "css" and { "--parser", "css" }
45 | -- end,
46 | -- },
47 | format.cmake_format.with {
48 | cmd = "cmake-format",
49 | },
50 | custom.format["tex-fmt"],
51 | -- format.latexindent.with {
52 | -- args = {
53 | -- "-g",
54 | -- "/dev/null",
55 | -- "-y",
56 | -- [[defaultIndent: " "]],
57 | -- },
58 | -- },
59 | format.shfmt.with {
60 | args = { "-s", "-i", "4" },
61 | },
62 | format.uncrustify,
63 | completion.spell,
64 | },
65 | }
66 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lsp/settings.lua:
--------------------------------------------------------------------------------
1 | require("lspconfig.ui.windows").default_options.border = "single"
2 |
3 | vim.diagnostic.config {
4 | virtual_text = false,
5 | signs = {
6 | text = {
7 | [vim.diagnostic.severity.ERROR] = "", -- ""
8 | [vim.diagnostic.severity.WARN] = "", -- ""
9 | [vim.diagnostic.severity.HINT] = "", -- ""
10 | [vim.diagnostic.severity.INFO] = "", -- ""
11 | },
12 |
13 | linehl = {
14 | [vim.diagnostic.severity.ERROR] = "DiagnosticSignError",
15 | [vim.diagnostic.severity.WARN] = "None",
16 | [vim.diagnostic.severity.HINT] = "None",
17 | [vim.diagnostic.severity.INFO] = "None",
18 | },
19 | numhl = {
20 | [vim.diagnostic.severity.ERROR] = "DiagnosticSignError",
21 | [vim.diagnostic.severity.WARN] = "DiagnosticSignWarn",
22 | [vim.diagnostic.severity.HINT] = "DiagnosticSignHint",
23 | [vim.diagnostic.severity.INFO] = "DiagnosticSignInfo",
24 | },
25 | },
26 | underline = true,
27 | update_in_insert = false,
28 | float = { border = "rounded", scope = "line", header = "" },
29 | }
30 |
31 | require("mason").setup {
32 | ui = {
33 | border = "single",
34 | },
35 | registries = {
36 | "github:mason-org/mason-registry",
37 | "lua:plugins.modules.lsp.custom",
38 | },
39 | }
40 |
41 | vim.api.nvim_create_autocmd("LspAttach", {
42 | callback = function(args)
43 | local buffer = args.buf
44 | local client = vim.lsp.get_client_by_id(args.data.client_id)
45 |
46 | if not client then
47 | return
48 | end
49 |
50 | vim.bo[buffer].formatexpr = "" -- yikes
51 |
52 | if client.server_capabilities.documentHighlightProvider then
53 | local group = vim.api.nvim_create_augroup("DocumentHighlight", {})
54 | vim.api.nvim_create_autocmd("CursorHold", {
55 | group = group,
56 | buffer = 0,
57 | callback = vim.lsp.buf.document_highlight,
58 | })
59 | vim.api.nvim_create_autocmd("CursorMoved", {
60 | group = group,
61 | buffer = 0,
62 | callback = vim.lsp.buf.clear_references,
63 | })
64 | end
65 |
66 | if client.server_capabilities.documentFormattingProvider then
67 | local group = vim.api.nvim_create_augroup("Formatting", {})
68 | vim.api.nvim_create_autocmd("BufWritePre", {
69 | group = group,
70 | buffer = 0,
71 | callback = function()
72 | if vim.g.format_on_save then
73 | require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] = nil
74 | vim.lsp.buf.format {
75 | timeout_ms = 3000,
76 | }
77 | end
78 | end,
79 | })
80 | end
81 | end,
82 | })
83 |
84 | vim.api.nvim_create_autocmd("LspAttach", {
85 | callback = function(args)
86 | local client = vim.lsp.get_client_by_id(args.data.client_id)
87 | if not client then
88 | return
89 | end
90 | client.server_capabilities.semanticTokensProvider = nil
91 | end,
92 | })
93 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/lualine.lua:
--------------------------------------------------------------------------------
1 | local M = { "nvim-lualine/lualine.nvim", lazy = false }
2 |
3 | function M.config()
4 | local theme = require "lualine.themes.tokyodark"
5 | local ok, p = pcall(require, "tokyodark.palette")
6 | if not ok then
7 | return
8 | end
9 | local colors = {
10 | diff_add = "#9ECE6A",
11 | diff_modify = "#7AA2F7",
12 | diff_remove = "#F7768E",
13 | border = p.bg5,
14 | }
15 |
16 | for _, session in pairs(theme.inactive) do
17 | session.gui = "underline"
18 | session.fg = colors.border
19 | end
20 |
21 | local custom_components = {
22 | pwd = function()
23 | return vim.fn.fnamemodify(vim.fn.getcwd(0, 0), ":~")
24 | end,
25 | formatting = {
26 | function()
27 | return ""
28 | end,
29 | cond = function()
30 | return vim.bo.filetype ~= "" and vim.g.format_on_save
31 | end,
32 | color = { fg = "#ff9e64" },
33 | },
34 | diagnostics = {
35 | function()
36 | local current = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
37 | local total = 0
38 | for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
39 | total = total + #vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.ERROR })
40 | end
41 | if total == 0 then
42 | return ""
43 | end
44 | return string.format("%%#Red# %d/%d", current, total)
45 | end,
46 | color = nil,
47 | },
48 | }
49 |
50 | local default_config = {
51 | options = {
52 | theme = theme,
53 | section_separators = { left = "", right = "" },
54 | component_separators = { left = "", right = "" },
55 | icons_enabled = true,
56 | globalstatus = true,
57 | },
58 | sections = {
59 | lualine_a = { { "mode", upper = true } },
60 | lualine_b = {
61 | { "branch", icon = "" },
62 | -- {
63 | -- require("noice").api.status.mode.get,
64 | -- cond = require("noice").api.status.mode.has,
65 | -- color = { fg = "#ff9e64" },
66 | -- },
67 | },
68 | lualine_c = {
69 | { custom_components.pwd },
70 | },
71 | lualine_x = { custom_components.diagnostics, custom_components.formatting, "filetype" },
72 | lualine_y = {
73 | {
74 | "diff",
75 | colored = true,
76 | diff_color = {
77 | added = { fg = colors.diff_add },
78 | modified = { fg = colors.diff_modify },
79 | removed = { fg = colors.diff_remove },
80 | },
81 | symbols = { added = "+", modified = "~", removed = "-" },
82 | },
83 | -- {
84 | -- require("noice").api.status.search.get,
85 | -- cond = require("noice").api.status.search.has,
86 | -- color = { fg = "#ff9e64" },
87 | -- },
88 | "location",
89 | },
90 | lualine_z = {},
91 | },
92 | inactive_sections = {
93 | lualine_a = {},
94 | lualine_b = {},
95 | lualine_c = { "filename" },
96 | lualine_x = {},
97 | lualine_y = {},
98 | lualine_z = {},
99 | },
100 | extensions = { { sections = { lualine_b = { "filetype" } }, filetypes = { "NvimTree" } } },
101 | }
102 |
103 | require("lualine").setup(default_config)
104 | end
105 |
106 | return M
107 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/init.lua:
--------------------------------------------------------------------------------
1 | local M = { "L3MON4D3/LuaSnip", version = "v2.*", lazy = false, dependencies = { { "rafamadriz/friendly-snippets" } } }
2 |
3 | function M.init()
4 | vim.keymap.set("i", "", function()
5 | require "luasnip.extras.select_choice"()
6 | end)
7 | local function reload_luasnip_config()
8 | require("luasnip").cleanup()
9 | for k in pairs(package.loaded) do
10 | if k:match ".*luasnip.snips.*" then
11 | package.loaded[k] = nil
12 | require(k)
13 | end
14 | end
15 | end
16 | vim.keymap.set("n", "rs", function()
17 | reload_luasnip_config()
18 | end, { desc = "Reload snippets" })
19 | end
20 |
21 | function M.config()
22 | local ls_types = require "luasnip.util.types"
23 | local util = require "luasnip.util.util"
24 |
25 | require("luasnip/loaders/from_vscode").lazy_load {}
26 |
27 | require("luasnip.config").setup {
28 | history = true,
29 | region_check_events = "CursorMoved",
30 | delete_check_events = "TextChangedI",
31 | updateevents = "TextChanged,TextChangedI,InsertLeave",
32 | enable_autosnippets = true,
33 | store_selection_keys = "",
34 | ext_opts = {
35 | [ls_types.choiceNode] = {
36 | active = {
37 | virt_text = { { " ", "Keyword" } },
38 | },
39 | },
40 | [ls_types.insertNode] = {
41 | active = {
42 | virt_text = { { "●", "Special" } },
43 | },
44 | },
45 | },
46 | parser_nested_assembler = function(_, snippet)
47 | local select = function(snip, no_move)
48 | snip.parent:enter_node(snip.indx)
49 | for _, node in ipairs(snip.nodes) do
50 | node:set_mark_rgrav(true, true)
51 | end
52 | if not no_move then
53 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true)
54 | local pos_begin, pos_end = snip.mark:pos_begin_end()
55 | util.normal_move_on(pos_begin)
56 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("v", true, false, true), "n", true)
57 | util.normal_move_before(pos_end)
58 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("o", true, false, true), "n", true)
59 | end
60 | end
61 |
62 | function snippet:jump_into(dir, no_move)
63 | if self.active then
64 | if dir == 1 then
65 | self:input_leave()
66 | return self.next:jump_into(dir, no_move)
67 | else
68 | select(self, no_move)
69 | return self
70 | end
71 | else
72 | self:input_enter()
73 | if dir == 1 then
74 | select(self, no_move)
75 | return self
76 | else
77 | return self.inner_last:jump_into(dir, no_move)
78 | end
79 | end
80 | end
81 |
82 | function snippet:jump_from(dir, no_move)
83 | if dir == 1 then
84 | return self.inner_first:jump_into(dir, no_move)
85 | else
86 | self:input_leave()
87 | return self.prev:jump_into(dir, no_move)
88 | end
89 | end
90 |
91 | return snippet
92 | end,
93 | }
94 | require "plugins.modules.luasnip.snips.cmake"
95 | require "plugins.modules.luasnip.snips.cpp"
96 | require "plugins.modules.luasnip.snips.lua"
97 | require "plugins.modules.luasnip.snips.python"
98 | require "plugins.modules.luasnip.snips.tex"
99 | require "plugins.modules.luasnip.snips.tex_math"
100 | end
101 |
102 | return M
103 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/mappings.lua:
--------------------------------------------------------------------------------
1 | local map = vim.keymap.set
2 |
3 | map("i", "", require "luasnip.extras.select_choice")
4 | -- map({ "i", "s" }, "", "luasnip-next-choice", {})
5 | -- map({ "i", "s" }, "", "luasnip-prev-choice", {})
6 |
7 | local function reload_luasnip_config()
8 | require("luasnip").cleanup()
9 | for k in pairs(package.loaded) do
10 | if k:match ".*luasnip.snips.*" then
11 | package.loaded[k] = nil
12 | require(k)
13 | end
14 | end
15 | end
16 |
17 | map("n", "rs", reload_luasnip_config, { desc = "Reload snippets" })
18 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/settings.lua:
--------------------------------------------------------------------------------
1 | local ls_types = require "luasnip.util.types"
2 | local util = require "luasnip.util.util"
3 |
4 | require("luasnip/loaders/from_vscode").lazy_load {}
5 |
6 | require("luasnip.config").setup {
7 | history = true,
8 | region_check_events = "CursorMoved",
9 | delete_check_events = "TextChangedI",
10 | updateevents = "TextChanged,TextChangedI,InsertLeave",
11 | enable_autosnippets = true,
12 | store_selection_keys = "",
13 | ext_opts = {
14 | [ls_types.choiceNode] = {
15 | active = {
16 | virt_text = { { " ", "Keyword" } },
17 | },
18 | },
19 | [ls_types.insertNode] = {
20 | active = {
21 | virt_text = { { "●", "Special" } },
22 | },
23 | },
24 | },
25 | parser_nested_assembler = function(_, snippet)
26 | local select = function(snip, no_move)
27 | snip.parent:enter_node(snip.indx)
28 | for _, node in ipairs(snip.nodes) do
29 | node:set_mark_rgrav(true, true)
30 | end
31 | if not no_move then
32 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true)
33 | local pos_begin, pos_end = snip.mark:pos_begin_end()
34 | util.normal_move_on(pos_begin)
35 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("v", true, false, true), "n", true)
36 | util.normal_move_before(pos_end)
37 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("o", true, false, true), "n", true)
38 | end
39 | end
40 |
41 | function snippet:jump_into(dir, no_move)
42 | if self.active then
43 | if dir == 1 then
44 | self:input_leave()
45 | return self.next:jump_into(dir, no_move)
46 | else
47 | select(self, no_move)
48 | return self
49 | end
50 | else
51 | self:input_enter()
52 | if dir == 1 then
53 | select(self, no_move)
54 | return self
55 | else
56 | return self.inner_last:jump_into(dir, no_move)
57 | end
58 | end
59 | end
60 |
61 | function snippet:jump_from(dir, no_move)
62 | if dir == 1 then
63 | return self.inner_first:jump_into(dir, no_move)
64 | else
65 | self:input_leave()
66 | return self.prev:jump_into(dir, no_move)
67 | end
68 | end
69 |
70 | return snippet
71 | end,
72 | }
73 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/snips/cmake.lua:
--------------------------------------------------------------------------------
1 | local ls = require "luasnip"
2 | local parse = ls.parser.parse_snippet
3 |
4 | local cmake_template = [[
5 | cmake_minimum_required(VERSION 3.10)
6 | project(${1:project})
7 | set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
8 | set(CMAKE_CXX_STANDARD 20)
9 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/lib)
10 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/lib)
11 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/bin)
12 | file(GLOB SOURCES src/*.cpp)
13 | add_executable(${2:app} \$SOURCES)
14 | target_include_directories(${2:app} PRIVATE include)
15 | ]]
16 |
17 | ls.add_snippets("cmake", {
18 | parse({ trig = "template" }, cmake_template),
19 | }, {})
20 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/snips/cpp.lua:
--------------------------------------------------------------------------------
1 | local ls = require "luasnip"
2 | local s = ls.snippet
3 | local t = ls.text_node
4 | local i = ls.insert_node
5 | local fmt = require("luasnip.extras.fmt").fmt
6 |
7 | ls.add_snippets("cpp", {
8 | s(
9 | "template",
10 | fmt(
11 | [[
12 | #include
13 |
14 | int main() {{
15 | {}
16 | return 0;
17 | }}
18 | ]],
19 | { i(0) }
20 | )
21 | ),
22 | })
23 |
24 | ls.add_snippets("cpp", {}, {})
25 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/snips/lua.lua:
--------------------------------------------------------------------------------
1 | local ls = require "luasnip"
2 |
3 | local s = ls.snippet
4 | local sn = ls.snippet_node
5 | local t = ls.text_node
6 | local i = ls.insert_node
7 | local f = ls.function_node
8 | local c = ls.choice_node
9 | local d = ls.dynamic_node
10 | local r = ls.restore_node
11 | local l = require("luasnip.extras").lambda
12 | local rep = require("luasnip.extras").rep
13 | local p = require("luasnip.extras").partial
14 | local m = require("luasnip.extras").match
15 | local n = require("luasnip.extras").nonempty
16 | local dl = require("luasnip.extras").dynamic_lambda
17 | local fmt = require("luasnip.extras.fmt").fmt
18 | local fmta = require("luasnip.extras.fmt").fmta
19 | local types = require "luasnip.util.types"
20 | local conds = require "luasnip.extras.expand_conditions"
21 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/snips/python.lua:
--------------------------------------------------------------------------------
1 | local ls = require "luasnip"
2 |
3 | local s = ls.snippet
4 | local t = ls.text_node
5 | local i = ls.insert_node
6 |
7 | ls.add_snippets("python", {
8 | s("importmatplotlib", {
9 | t { "from matplotlib import pyplot as plt", "" },
10 | i(0),
11 | }),
12 | s("importnumpy", {
13 | t { "import numpy as np", "" },
14 | i(0),
15 | }),
16 | s("defmain", {
17 | t { "def main():", "\t" },
18 | i(0, "..."),
19 | t { "", "", "" },
20 | t { 'if __name__ == "__main__":' },
21 | t { "", "\tmain()" },
22 | i(0),
23 | }),
24 | s("if__name__", {
25 | t { 'if __name__ == "__main__":', "\t" },
26 | i(0),
27 | }),
28 | })
29 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/luasnip/snips/tex.lua:
--------------------------------------------------------------------------------
1 | local ls = require "luasnip"
2 | local parse = ls.parser.parse_snippet
3 | local s = ls.snippet
4 | local t = ls.text_node
5 | local i = ls.insert_node
6 | local d = ls.dynamic_node
7 | local sn = ls.snippet_node
8 | local f = ls.function_node
9 | local fmt = require("luasnip.extras.fmt").fmt
10 | local rep = require("luasnip.extras").rep
11 | local events = require "luasnip.util.events"
12 |
13 | ls.add_snippets("tex", {
14 | s("centered_comment", {
15 | f(function(args)
16 | local title = args[1][1] or ""
17 | local total_length = 80
18 | local title_length = #title
19 | local padding = math.max(0, total_length - title_length - 2)
20 | local left_padding = math.floor(padding / 2)
21 | return string.rep("%", left_padding) .. " "
22 | end, { 1 }),
23 | i(1, "Title"), -- Insert node for the title
24 | f(function(args)
25 | local title = args[1][1] or ""
26 | local total_length = 80
27 | local title_length = #title
28 | local padding = math.max(0, total_length - title_length - 2)
29 | local left_padding = math.floor(padding / 2)
30 | local right_padding = padding - left_padding
31 | return " " .. string.rep("%", right_padding)
32 | end, { 1 }),
33 | }),
34 | })
35 |
36 | local function div(tag, stag)
37 | return s({ trig = tag }, {
38 | t("\\" .. tag .. "{"),
39 | i(1),
40 | t "}",
41 | d(2, function(args)
42 | local text
43 | if args[1] == "" then
44 | text = tag
45 | else
46 | text = args[1][1]:gsub(" ", "_"):lower()
47 | end
48 | return sn(nil, { t("\\label{" .. stag .. ":"), i(1, text), t "}", t { "", "" }, i(0) })
49 | end, { 1 }),
50 | })
51 | end
52 |
53 | -- use mathematica to calculate whatever is written before leaving the snippet
54 | ls.add_snippets("tex", {
55 | s({ trig = "math" }, { i(1), t " ", i(0) }, {
56 | callbacks = {
57 | [1] = {
58 | [events.leave] = function(node)
59 | local from_pos, to_pos = node.mark:pos_begin_end_raw()
60 | local lines = vim.api.nvim_buf_get_lines(0, from_pos[1], to_pos[1] + 1, false)
61 | local script = ([[!wolframscript -c "ToString@TeXForm[%s]"]]):format(node:get_text()[1])
62 | local output = vim.split(vim.api.nvim_exec(script, true), "\n")
63 | output = output[#output - 1]
64 | if #lines == 1 then
65 | vim.api.nvim_buf_set_text(0, from_pos[1], from_pos[2], to_pos[1], to_pos[2], { output })
66 | end
67 | end,
68 | },
69 | },
70 | }),
71 | }, {})
72 |
73 | ls.add_snippets("tex", {
74 | s("mk", { t { "$" }, i(1), t { "$ " }, i(0) }),
75 | s("dk", {
76 | t { "\\[", "\t" },
77 | i(1),
78 | t { "", "\\]", "" },
79 | i(0),
80 | }),
81 | }, { type = "autosnippets" })
82 |
83 | local tex_template = [[
84 | \documentclass[a4paper,12pt]{article}
85 | \usepackage[a4paper, margin=1in, total={20cm,27cm}]{geometry}
86 | \usepackage{import}
87 | \usepackage{pdfpages}
88 | \usepackage{transparent}
89 | \usepackage{xcolor}
90 | \usepackage{textcomp}
91 | \usepackage{amsmath, amssymb}
92 | \usepackage{graphicx}
93 | \usepackage{tikz}
94 | \usepackage{wrapfig}
95 | \title{$1}
96 | \author{$2}
97 | \begin{document}
98 | \maketitle
99 | \tableofcontents
100 | $0
101 | \addcontentsline{toc}{section}{Unnumbered Section}
102 | \end{document}
103 | ]]
104 |
105 | local tex_table = [[
106 | \begin{center}
107 | \begin{tabular}{ c c c }
108 | cell1 & cell2 & cell3 \\\\
109 | \\hline
110 | cell4 & cell5 & cell6 \\\\
111 | \\hline
112 | cell7 & cell8 & cell9
113 | \end{tabular}
114 | \end{center}
115 | ]]
116 |
117 | ls.add_snippets("tex", {
118 | s([["]], fmt([[``{}'']], i(1))),
119 | parse({ trig = "template" }, tex_template),
120 | parse({ trig = "table" }, tex_table),
121 | s({ trig = "frame" }, {
122 | t { "\\begin{frame}", "\t" },
123 | i(1),
124 | t { "", "\\end{frame}", "" },
125 | i(0),
126 | }),
127 | s({ trig = "begin" }, {
128 | t "\\begin{",
129 | i(1),
130 | t { "}", "\t" },
131 | i(2),
132 | t { "", "\\end{" },
133 | rep(1),
134 | t { "}", "" },
135 | i(0),
136 | }),
137 | div("chapter", "chap"),
138 | div("section", "sec"),
139 | div("subsection", "subsec"),
140 | div("subsubsection", "subsubsec"),
141 | s("superscript", { t "\\textsuperscript{", i(1), t "}", i(0) }),
142 | s("subscript", { t "\\subscript{", i(1), t "}", i(0) }),
143 | s("rm", { t "\\textrm{", i(1), t "}", i(0) }),
144 | s("gls", { t "\\gls{", i(1), t "}", i(0) }),
145 | s("glspl", { t "\\gls{", i(1), t "}", i(0) }),
146 | s("bold", { t "\\textbf{", i(1), t "}", i(0) }),
147 | s("italic", { t "\\textit{", i(1), t "}", i(0) }),
148 | s("smallcaps", { t "\\textsc{", i(1), t "}", i(0) }),
149 | s("reals", { t "\\mathbb{R}", i(0) }),
150 | }, {})
151 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/navic.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "SmiteshP/nvim-navic",
3 | lazy = false,
4 | opts = function()
5 | return {
6 | separator = " ",
7 | highlight = true,
8 | depth_limit = 5,
9 | }
10 | end,
11 | config = function(_, opts)
12 | vim.g.navic_silence = true
13 | require("nvim-navic").setup(opts)
14 | end,
15 | }
16 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/neogen.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "danymat/neogen",
3 | cmd = "Neogen",
4 | dependencies = "nvim-treesitter/nvim-treesitter",
5 | opts = {
6 | enabled = true,
7 | },
8 | keys = {
9 | { "gd", "Neogen", desc = "Neogen" },
10 | },
11 | }
12 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/neogit.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "neogitorg/neogit",
3 | keys = {
4 | {
5 | "N",
6 | function()
7 | require("neogit").open()
8 | end,
9 | desc = "Neogit",
10 | },
11 | {
12 | "n",
13 | function()
14 | require("neogit").open { "commit" }
15 | end,
16 | desc = "Neogit commit",
17 | },
18 | },
19 | dependencies = "nvim-lua/plenary.nvim",
20 | opts = {
21 | disable_commit_confirmation = true,
22 | integrations = {
23 | diffview = true,
24 | },
25 | sections = {
26 | staged = {
27 | folded = false,
28 | hidden = false,
29 | },
30 | untracked = {
31 | folded = true,
32 | hidden = false,
33 | },
34 | unstaged = {
35 | folded = true,
36 | hidden = false,
37 | },
38 | },
39 | },
40 | }
41 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/neotest.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "rcarriga/neotest",
3 | dependencies = {
4 | { "nvim-lua/plenary.nvim" },
5 | { "nvim-treesitter/nvim-treesitter" },
6 | { "antoinemadec/FixCursorHold.nvim" },
7 | { "rcarriga/neotest-python" },
8 | { "rouge8/neotest-rust" },
9 | { "nvim-neotest/nvim-nio" },
10 | },
11 | ft = { "python" },
12 | opts = {
13 | status = {
14 | enabled = true,
15 | signs = true,
16 | virtual_text = false,
17 | },
18 | },
19 | config = function(_, opts)
20 | opts.adapters = {
21 | require "neotest-python" {},
22 | require "neotest-rust" {
23 | args = { "--no-capture" },
24 | dap_adapter = "lldb",
25 | },
26 | }
27 | require("neotest").setup { opts }
28 | end,
29 | }
30 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/neotree.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "nvim-neo-tree/neo-tree.nvim",
3 | cmd = "Neotree",
4 | dependencies = {
5 | { "MunifTanjim/nui.nvim" },
6 | },
7 | config = function()
8 | vim.g.neo_tree_remove_legacy_commands = 1
9 |
10 | require("neo-tree").setup {
11 | filesystem = {
12 | follow_current_file = true,
13 | hijack_netrw_behavior = "open_current",
14 | },
15 | }
16 | end,
17 | }
18 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/noice.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "folke/noice.nvim",
3 | event = "VeryLazy",
4 | opts = {
5 | routes = {
6 | {
7 | view = "popup",
8 | filter = { event = "msg_show", cmdline = true, min_height = 2 },
9 | },
10 | {
11 | view = "popup",
12 | filter = { event = "msg_show", min_height = 20 },
13 | },
14 | },
15 | messages = {
16 | enabled = true,
17 | view = "notify",
18 | view_error = "notify",
19 | },
20 | notify = {
21 | enabled = true,
22 | view = "mini",
23 | },
24 | cmdline = {
25 | view = "cmdline",
26 | format = {
27 | cmdline = false,
28 | -- search_down = false,
29 | -- search_up = false,
30 | -- filter = false,
31 | help = false,
32 | lua = false,
33 | },
34 | },
35 | lsp = {
36 | override = {
37 | ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
38 | ["vim.lsp.util.stylize_markdown"] = true,
39 | ["cmp.entry.get_documentation"] = true,
40 | },
41 | },
42 | presets = {
43 | bottom_search = true,
44 | command_palette = false,
45 | long_message_to_split = true,
46 | inc_rename = false,
47 | lsp_doc_border = true,
48 | },
49 | },
50 | dependencies = {
51 | "MunifTanjim/nui.nvim",
52 | },
53 | }
54 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/notify.lua:
--------------------------------------------------------------------------------
1 | return {
2 | -- "rcarriga/nvim-notify",
3 | -- keys = {
4 | -- {
5 | -- "un",
6 | -- function()
7 | -- require("notify").dismiss { silent = true, pending = true }
8 | -- end,
9 | -- desc = "Dismiss all Notifications",
10 | -- },
11 | -- },
12 | -- config = function()
13 | -- require("notify").setup {
14 | -- background_colour = "None",
15 | -- stages = "fade_in_slide_out",
16 | -- on_open = nil,
17 | -- on_close = nil,
18 | -- render = "compact",
19 | -- timeout = 1500,
20 | -- minimum_width = 20,
21 | -- max_height = function()
22 | -- return math.floor(vim.o.lines * 0.75)
23 | -- end,
24 | -- max_width = function()
25 | -- return math.floor(vim.o.columns * 0.75)
26 | -- end,
27 | -- icons = {
28 | -- ERROR = "",
29 | -- WARN = "",
30 | -- INFO = "",
31 | -- DEBUG = "",
32 | -- TRACE = "✎",
33 | -- },
34 | -- }
35 | -- require("telescope").load_extension "notify"
36 | -- -- vim.notify = require "notify"
37 | -- end,
38 | }
39 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/obsidian.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "epwalsh/obsidian.nvim",
3 | version = "*",
4 | lazy = true,
5 | ft = "markdown",
6 | dependencies = {
7 | "nvim-lua/plenary.nvim",
8 | },
9 | opts = {
10 | workspaces = {
11 | {
12 | name = "tiagovla",
13 | path = "~/.obsidian/tiagovla",
14 | },
15 | },
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/oil.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "stevearc/oil.nvim",
3 | config = function()
4 | require("oil").setup {
5 | keymaps = {
6 | ["q"] = require("oil").close,
7 | ["-"] = require("oil").close,
8 | },
9 | cleanup_delay_ms = 500,
10 | float = {
11 | max_height = 20,
12 | max_width = 60,
13 | },
14 | }
15 | vim.keymap.set("n", "-", function()
16 | if vim.bo.filetype == "oil" then
17 | require("oil").close()
18 | else
19 | require("oil").open()
20 | end
21 | end, { desc = "File navigation" })
22 | end,
23 | lazy = false,
24 | }
25 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/peek.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "toppair/peek.nvim",
3 | build = "deno task --quiet build:fast",
4 | ft = "markdown",
5 | init = function()
6 | vim.api.nvim_create_user_command("Peek", function()
7 | local peek = require "peek"
8 | local toggle = peek.close and peek.is_open() or peek.open
9 | toggle()
10 | end, {})
11 | end,
12 | opts = { theme = "dark" },
13 | }
14 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/spectre.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "nvim-pack/nvim-spectre",
3 | config = true,
4 | lazy = false,
5 | init = function()
6 | vim.keymap.set("n", "S", 'lua require("spectre").toggle()', {
7 | desc = "Toggle Spectre",
8 | })
9 | vim.keymap.set("n", "sw", 'lua require("spectre").open_visual({select_word=true})', {
10 | desc = "Search current word",
11 | })
12 | vim.keymap.set("v", "sw", 'lua require("spectre").open_visual()', {
13 | desc = "Search current word",
14 | })
15 | vim.keymap.set("n", "sp", 'lua require("spectre").open_file_search({select_word=true})', {
16 | desc = "Search on current file",
17 | })
18 | end,
19 | }
20 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/surround.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "kylechui/nvim-surround",
3 | event = "InsertEnter",
4 | config = true,
5 | }
6 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/telescope.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "nvim-telescope/telescope.nvim",
3 | version = "*",
4 | cmd = "Telescope",
5 | dependencies = {
6 | {
7 | "tiagovla/telescope-project.nvim",
8 | dev = true,
9 | lazy = false,
10 | },
11 | { "nvim-telescope/telescope-media-files.nvim" },
12 | { "nvim-telescope/telescope-file-browser.nvim" },
13 | { "jvgrootveld/telescope-zoxide" },
14 | { "nvim-telescope/telescope-fzf-native.nvim" },
15 | {
16 | "nvim-telescope/telescope-file-browser.nvim",
17 | dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
18 | },
19 | },
20 | }
21 |
22 | function M.init()
23 | vim.keymap.set({ "n", "v" }, "tc", "Telescope commands", { desc = "Show Commands" })
24 | vim.keymap.set("n", "ts", "Telescope current_buffer_fuzzy_find", { desc = "FZF current buffer" })
25 | vim.keymap.set("n", "tf", "Telescope find_files", { desc = "Find files" })
26 | vim.keymap.set("n", "tg", "Telescope live_grep", { desc = "Live grep" })
27 | vim.keymap.set("n", "tG", "Telescope git_files", { desc = "Git files" })
28 | vim.keymap.set("n", "to", "Telescope oldfiles", { desc = "Old files" })
29 | vim.keymap.set("n", "tB", "Telescope buffers", { desc = "Buffers" })
30 | vim.keymap.set("n", "tb", "Telescope file_browser", { desc = "File Browser" })
31 | vim.keymap.set("n", "th", "Telescope help_tags", { desc = "Help tags" })
32 | vim.keymap.set("n", "tC", "Telescope colorscheme", { desc = "Colorscheme" })
33 | vim.keymap.set("n", "tp", "Telescope project", { desc = "Project" })
34 | vim.keymap.set("n", "td", "Telescope zoxide list", { desc = "Zoxide" })
35 | vim.keymap.set("n", "tm", "Telescope man_pages", { desc = "Man pages" })
36 | vim.keymap.set("n", "tn", "Telescope notify", { desc = "Notifications" })
37 | end
38 |
39 | function M.config()
40 | local custom_theme = {
41 | pickers = {
42 | find_files = {
43 | find_command = { "rg", "--no-ignore", "--type=file", "--hiden", "--smart-case" },
44 | -- find_command = { "rg", "--type=file", "--hidden", "--smart-case" },
45 | },
46 | live_grep = {
47 | only_sort_text = true,
48 | },
49 | },
50 | layout_config = {
51 | prompt_position = "bottom",
52 | horizontal = {
53 | preview_width = 0.55,
54 | results_width = 0.8,
55 | },
56 | vertical = {
57 | mirror = false,
58 | },
59 | width = 0.87,
60 | height = 0.80,
61 | preview_cutoff = 120,
62 | },
63 | scroll_strategy = "cycle",
64 | vimgrep_arguments = {
65 | "rg",
66 | "--color=never",
67 | "--no-heading",
68 | "--with-filename",
69 | "--line-number",
70 | "--column",
71 | "--smart-case",
72 | },
73 | prompt_prefix = ">",
74 | path_display = { "truncate" },
75 | selection_strategy = "reset",
76 | sorting_strategy = "descending",
77 | layout_strategy = "horizontal",
78 | file_sorter = require("telescope.sorters").get_fuzzy_file,
79 | file_ignore_patterns = {},
80 | generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
81 | winblend = 0,
82 | border = {},
83 | borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
84 | color_devicons = true,
85 | use_less = true,
86 | set_env = { ["COLORTERM"] = "truecolor" },
87 | file_previewer = require("telescope.previewers").vim_buffer_cat.new,
88 | grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
89 | qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
90 | buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
91 | mappings = {
92 | n = {
93 | [""] = require("telescope.actions").delete_buffer,
94 | },
95 | },
96 | }
97 | require("telescope").setup {
98 | defaults = custom_theme,
99 | extensions = {
100 | fzf = {
101 | fuzzy = true,
102 | override_generic_sorter = true,
103 | override_file_sorter = true,
104 | case_mode = "smart_case",
105 | },
106 | },
107 | }
108 | require("telescope").load_extension "project"
109 | require("telescope").load_extension "zoxide"
110 | require("telescope").load_extension "file_browser"
111 | require("telescope").load_extension "fzf"
112 | local builtin = require "telescope.builtin"
113 | require("telescope._extensions.zoxide.config").setup {
114 | mappings = {
115 | [""] = {
116 | keepinsert = true,
117 | action = function(selection)
118 | builtin.find_files { cwd = selection.path }
119 | end,
120 | after_action = function(selection)
121 | vim.cmd("cd " .. selection.path)
122 | end,
123 | },
124 | },
125 | }
126 | end
127 |
128 | return M
129 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/tmux.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "aserowy/tmux.nvim",
3 | event = "VeryLazy",
4 | opts = {
5 | copy_sync = {
6 | enable = true,
7 | },
8 | navigation = {
9 | enable_default_keybindings = true,
10 | },
11 | resize = {
12 | enable_default_keybindings = true,
13 | },
14 | },
15 | }
16 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/toggleterm.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "akinsho/toggleterm.nvim",
3 | lazy = false,
4 | }
5 |
6 | local function slice_from_match(list, match)
7 | local function find_index(tbl, element)
8 | for i, v in ipairs(tbl) do
9 | if v == element then
10 | return i
11 | end
12 | end
13 | return nil
14 | end
15 | local index = find_index(list, match)
16 | if index then
17 | return { unpack(list, index + 1) }
18 | else
19 | return list
20 | end
21 | end
22 |
23 | function M.init()
24 | vim.keymap.set({ "n", "i", "v", "t", "x" }, "", "")
25 | vim.keymap.set({ "n", "v" }, "", "TermFloat")
26 | vim.keymap.set({ "n", "v" }, "", "TermBottom")
27 | vim.keymap.set({ "n", "v" }, "G", "Lazygit")
28 |
29 | local function set_terminal_keymaps()
30 | vim.keymap.set("t", "", "TermFloat")
31 | vim.keymap.set("t", "", "TermBottom")
32 | vim.keymap.set("t", "", [[h]])
33 | vim.keymap.set("t", "", [[j]])
34 | vim.keymap.set("t", "", [[k]])
35 | vim.keymap.set("t", "", [[l]])
36 | end
37 | vim.api.nvim_create_autocmd("TermOpen", { pattern = "term://*", callback = set_terminal_keymaps })
38 | end
39 |
40 | function M.config()
41 | require("toggleterm").setup {
42 | size = 20,
43 | hide_numbers = true,
44 | autochdir = true,
45 | start_in_insert = true,
46 | insert_mappings = true,
47 | shade_terminals = true,
48 | shading_factor = 2,
49 | persist_size = true,
50 | close_on_exit = true,
51 | direction = "float",
52 | highlights = { FloatBorder = { guifg = "#4A5057" } },
53 | float_opts = {
54 | border = "curved",
55 | winblend = 0,
56 | },
57 | }
58 |
59 | local Terminal = require("toggleterm.terminal").Terminal
60 |
61 | local lazygit = Terminal:new { cmd = "lazygit", hidden = true, direction = "tab" }
62 |
63 | local lines = {}
64 | local running_cmd = false
65 |
66 | local on_data = function(_, _, data)
67 | for i, line in ipairs(data) do
68 | data[i] = line:gsub("\r", ""):gsub("\27%[[0-9;]*m", "")
69 | end
70 | for _, v in pairs(data) do
71 | if v == "async_make_done" then
72 | running_cmd = false
73 | local output = slice_from_match(lines, "async_make_start")
74 | output = vim.tbl_filter(function(line)
75 | return line ~= ""
76 | end, output)
77 |
78 | local efm = vim.api.nvim_get_option_value("errorformat", { buf = 0 })
79 | vim.fn.setqflist({}, " ", {
80 | title = "make",
81 | lines = output,
82 | efm = efm,
83 | })
84 | vim.api.nvim_command "doautocmd QuickFixCmdPost"
85 | vim.notify "Make command ended"
86 | end
87 | end
88 |
89 | if running_cmd then
90 | vim.list_extend(lines, data)
91 | end
92 | end
93 |
94 | local on_exit = function()
95 | running_cmd = false
96 | lines = {}
97 | end
98 |
99 | local term_float = Terminal:new {
100 | hidden = true,
101 | direction = "float",
102 | on_stdout = on_data,
103 | on_stderr = on_data,
104 | on_exit = on_exit,
105 | }
106 |
107 | local function make()
108 | require "toggleterm.terminal"
109 | if not term_float:is_open() then
110 | term_float:toggle()
111 | term_float:toggle()
112 | end
113 | lines = {}
114 | term_float:send({ "echo async_make_start; make; echo async_make_done" }, false)
115 | running_cmd = true
116 | vim.notify "Make command running..."
117 | end
118 |
119 | vim.api.nvim_create_user_command("Make", make, {})
120 | vim.keymap.set({ "n", "i", "x", "t" }, "", "Make")
121 | vim.keymap.set({ "n", "i", "x" }, "", "Make")
122 |
123 | local function _smart_toggle(terminal, size, direction)
124 | if terminal:is_open() and terminal.direction ~= direction then
125 | terminal:toggle(size, direction)
126 | terminal:toggle(size, direction)
127 | elseif terminal:is_open() and not terminal:is_focused() then
128 | terminal:focus()
129 | terminal:set_mode "i"
130 | else
131 | terminal:toggle(size, direction)
132 | end
133 | end
134 |
135 | local function setup_cmd(cmd, term, size, direction)
136 | vim.api.nvim_create_user_command(cmd, function()
137 | _smart_toggle(term, size, direction)
138 | end, {})
139 | end
140 | setup_cmd("Lazygit", lazygit, nil, "tab")
141 | setup_cmd("TermFloat", term_float, 20, "float")
142 | setup_cmd("TermBottom", term_float, 12, "horizontal")
143 | setup_cmd("TermRight", term_float, 50, "vertical")
144 | end
145 |
146 | return M
147 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/tokyodark.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "tiagovla/tokyodark.nvim",
3 | lazy = false,
4 | dev = true,
5 | priority = 1000,
6 | opts = {
7 | transparent_background = true,
8 | custom_highlights = function(hl, p)
9 | return {
10 | ["LspInlayHint"] = { bg = "#1C1C2A", fg = "#9AA0A7" },
11 | -- ["Conceal"] = { bg = "NONE" },
12 | ["@module"] = { link = "TSType" },
13 | ["@property"] = { link = "Identifier" },
14 | ["@variable"] = { fg = "#Afa8ea" },
15 | ["@lsp.type.variable"] = { fg = "#Afa8ea" },
16 | ["@module.latex"] = { link = "Red" },
17 | ["@markup.link.latex"] = { link = "Blue" },
18 | ["CmpItemKindCopilot"] = { fg = "#6CC644" },
19 | NoiceLspProgressSpinner = { bg = "#1C1C2A" },
20 | NoiceLspProgressClient = { bg = "#1C1C2A" },
21 | NoiceLspProgressTitle = { bg = "#1C1C2A" },
22 | NoiceMini = { bg = "#1C1C2A" },
23 | NoiceCmdlineIconSearch = { link = "Blue" },
24 | }
25 | end,
26 | },
27 | config = function(_, opts)
28 | require("tokyodark").setup(opts)
29 | require("tokyodark").colorscheme()
30 | end,
31 | }
32 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/treesitter.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "nvim-treesitter/nvim-treesitter",
3 | version = false,
4 | build = ":TSUpdate",
5 | lazy = false,
6 | dependencies = {
7 | { "nvim-treesitter/nvim-treesitter-textobjects" },
8 | { "nvim-treesitter/playground" },
9 | },
10 | }
11 |
12 | function M.config()
13 | local treesitter = require "nvim-treesitter.configs"
14 | treesitter.setup {
15 | ensure_installed = "all",
16 | ignore_install = { "comment" },
17 | highlight = {
18 | enable = true,
19 | additional_vim_regex_highlighting = false,
20 | use_languagetree = false,
21 | disable = function(_, bufnr)
22 | local buf_name = vim.api.nvim_buf_get_name(bufnr)
23 | local file_size = vim.api.nvim_call_function("getfsize", { buf_name })
24 | return file_size > 256 * 1024
25 | end,
26 | },
27 | incremental_selection = {
28 | enable = true,
29 | keymaps = {
30 | init_selection = "gnn",
31 | node_incremental = "gnn",
32 | scope_incremental = "gns",
33 | node_decremental = "gnp",
34 | },
35 | },
36 | context_commentstring = {
37 | enable = true,
38 | },
39 | textobjects = {
40 | select = {
41 | enable = true,
42 | lookahead = true,
43 | keymaps = {
44 | ["af"] = "@function.outer",
45 | ["if"] = "@function.inner",
46 | ["ac"] = "@class.outer",
47 | ["ic"] = "@class.inner",
48 | ["iB"] = "@block.inner",
49 | ["aB"] = "@block.outer",
50 | ["iF"] = "@frame.inner",
51 | ["aF"] = "@frame.outer",
52 | },
53 | },
54 | swap = {
55 | enable = true,
56 | disable = { "lua" },
57 | swap_next = {
58 | ["a"] = "@parameter.inner",
59 | },
60 | swap_previous = {
61 | ["A"] = "@parameter.inner",
62 | },
63 | },
64 | move = {
65 | enable = true,
66 | set_jumps = true,
67 | goto_next_start = {
68 | ["]]"] = "@function.outer",
69 | },
70 | goto_next_end = {
71 | ["]["] = "@function.outer",
72 | },
73 | goto_previous_start = {
74 | ["[["] = "@function.outer",
75 | },
76 | goto_previous_end = {
77 | ["[]"] = "@function.outer",
78 | },
79 | },
80 | },
81 | }
82 | end
83 |
84 | return M
85 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/trouble.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "folke/trouble.nvim",
3 | event = "VeryLazy",
4 | dependencies = { "nvim-tree/nvim-web-devicons" },
5 | keys = {
6 | {
7 | "e",
8 | function()
9 | local api = require "trouble.api"
10 | if api.is_open() then
11 | api.close()
12 | else
13 | vim.cmd.Trouble "diagnostics"
14 | end
15 | end,
16 | desc = "Toggle Trouble",
17 | },
18 | },
19 | opts = {
20 | keys = {
21 | [""] = "prev",
22 | [""] = "next",
23 | },
24 | },
25 | config = true,
26 | init = function()
27 | vim.api.nvim_create_autocmd("BufEnter", {
28 | callback = function()
29 | if #vim.api.nvim_list_wins() == 1 and vim.api.nvim_buf_get_name(0):match "Trouble" ~= nil then
30 | vim.cmd.quit()
31 | end
32 | end,
33 | })
34 | end,
35 | }
36 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/plugins/modules/which-key.lua:
--------------------------------------------------------------------------------
1 | local M = {
2 | "folke/which-key.nvim",
3 | event = "VeryLazy",
4 | }
5 |
6 | function M.config()
7 | require("which-key").setup {
8 | plugins = {
9 | marks = true,
10 | registers = true,
11 | spelling = {
12 | enabled = false,
13 | },
14 | presets = {
15 | operators = false,
16 | motions = false,
17 | text_objects = false,
18 | windows = true,
19 | nav = true,
20 | z = true,
21 | g = true,
22 | },
23 | },
24 | icons = {
25 | breadcrumb = "»",
26 | separator = "➜",
27 | group = "+",
28 | },
29 | layout = {
30 | height = { min = 4, max = 25 },
31 | width = { min = 20, max = 50 },
32 | spacing = 3,
33 | align = "left",
34 | },
35 | }
36 | local wk = require "which-key"
37 | wk.add({
38 | { "d", group = "Dap Debugger" },
39 | { "g", group = "General" },
40 | { "h", group = "Git Signs" },
41 | { "t", group = "Telescope" },
42 | }, {})
43 | end
44 |
45 | return M
46 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/tiagovla/autocmds.lua:
--------------------------------------------------------------------------------
1 | -- highlight on yank
2 | vim.api.nvim_create_autocmd("TextYankPost", {
3 | group = vim.api.nvim_create_augroup("HighlightOnYank", {}),
4 | callback = function()
5 | vim.highlight.on_yank { higroup = "IncSearch", timeout = 300 }
6 | end,
7 | })
8 |
9 | -- scroll off EOF
10 | vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI", "BufEnter" }, {
11 | group = vim.api.nvim_create_augroup("ScrollOffEOF", {}),
12 | callback = function()
13 | local win_h = vim.api.nvim_win_get_height(0)
14 | local off = math.min(vim.o.scrolloff, math.floor(win_h / 2))
15 | local dist = vim.fn.line "$" - vim.fn.line "."
16 | local rem = vim.fn.line "w$" - vim.fn.line "w0" + 1
17 | if dist < off and win_h - rem + dist < off then
18 | local view = vim.fn.winsaveview()
19 | view.topline = view.topline + off - (win_h - rem + dist)
20 | vim.fn.winrestview(view)
21 | end
22 | end,
23 | })
24 |
25 | -- change colorcolumn if visual text intersects it
26 | local cc_default_hi = vim.api.nvim_get_hl_by_name("ColorColumn", true)
27 | vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI", "BufEnter" }, {
28 | group = vim.api.nvim_create_augroup("CCHighlight", {}),
29 | callback = function()
30 | local cc = tonumber(vim.api.nvim_win_get_option(0, "colorcolumn"))
31 | if cc ~= nil then
32 | local lines = vim.api.nvim_buf_get_lines(0, vim.fn.line "w0", vim.fn.line "w$", true)
33 | local max_col = 0
34 | for _, line in pairs(lines) do
35 | max_col = math.max(max_col, vim.fn.strdisplaywidth(line))
36 | end
37 | if max_col <= cc then
38 | vim.api.nvim_set_hl(0, "ColorColumn", cc_default_hi)
39 | else
40 | vim.api.nvim_set_hl(0, "ColorColumn", { bg = 2697787 })
41 | end
42 | end
43 | end,
44 | })
45 |
46 | -- keep cursor position after yanking
47 | local cursor_position
48 | vim.api.nvim_create_autocmd({ "VimEnter", "CursorMoved" }, {
49 | group = vim.api.nvim_create_augroup("RestoreCursor", {}),
50 | callback = function()
51 | cursor_position = vim.api.nvim_win_get_cursor(0)
52 | end,
53 | })
54 | vim.api.nvim_create_autocmd("TextYankPost", {
55 | group = vim.api.nvim_create_augroup("RestoreCursor", { clear = false }),
56 | callback = function()
57 | if vim.v.event.operator == "y" then
58 | vim.api.nvim_win_set_cursor(0, cursor_position)
59 | end
60 | end,
61 | })
62 |
63 | -- no comments next line
64 | vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
65 | callback = function()
66 | vim.cmd "set formatoptions-=cro"
67 | end,
68 | })
69 |
70 | -- templates
71 | vim.api.nvim_create_autocmd("BufNewFile", {
72 | callback = function()
73 | local c_path = vim.fn.stdpath "config" .. "/templates/"
74 | local fe, ft = vim.fn.expand "%:e", vim.bo.filetype
75 | if ft == "make" then
76 | vim.cmd("0r " .. c_path .. "make") -- Makefile
77 | elseif ft == "cmake" then
78 | vim.cmd("0r " .. c_path .. "cmake") -- CMakeLists.txt
79 | elseif ft == "tex" then
80 | vim.cmd("0r " .. c_path .. "tex.tex") -- latex.tex
81 | end
82 | end,
83 | })
84 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/tiagovla/commands.lua:
--------------------------------------------------------------------------------
1 | local function to_numpy_array(args)
2 | local bufnr = vim.api.nvim_get_current_buf()
3 | local i = (args.line1 or vim.api.nvim_buf_get_mark(bufnr, "<")[1]) - 1
4 | local e = args.line2 or vim.api.nvim_buf_get_mark(bufnr, ">")[1]
5 | local lines = vim.api.nvim_buf_get_lines(0, i, e, false)
6 |
7 | for k, line in ipairs(lines) do
8 | lines[k] = " [" .. table.concat(vim.split(vim.trim(line):gsub("%s+", " "), " ", true), ", ") .. "],"
9 | end
10 | table.insert(lines, 1, "np.array([")
11 | table.insert(lines, "])")
12 | vim.api.nvim_buf_set_lines(0, i, e, true, lines)
13 | end
14 |
15 | local function redir(ctx)
16 | local lines = vim.split(vim.api.nvim_exec(ctx.args, true), "\n", { plain = true })
17 | vim.cmd "new"
18 | vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
19 | vim.opt_local.modified = false
20 | end
21 |
22 | vim.api.nvim_create_user_command("NumpyArray", to_numpy_array, { range = true })
23 | vim.api.nvim_create_user_command("Redir", redir, { nargs = "+", complete = "command" })
24 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/tiagovla/globals.lua:
--------------------------------------------------------------------------------
1 | RELOAD = function(...)
2 | return require("plenary.reload").reload_module(...)
3 | end
4 |
5 | R = function(name)
6 | RELOAD(name)
7 | return require(name)
8 | end
9 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/tiagovla/init.lua:
--------------------------------------------------------------------------------
1 | require "tiagovla.settings"
2 | require "tiagovla.globals"
3 |
4 | vim.api.nvim_create_autocmd("User", {
5 | pattern = "VeryLazy",
6 | callback = function()
7 | require "tiagovla.mappings"
8 | require "tiagovla.autocmds"
9 | require "tiagovla.commands"
10 | end,
11 | })
12 |
--------------------------------------------------------------------------------
/neovim/.config/nvim/lua/tiagovla/mappings.lua:
--------------------------------------------------------------------------------
1 | local utils = require "tiagovla.utils"
2 |
3 | local M = {}
4 |
5 | function M.setup()
6 | M.general()
7 | M.movements()
8 | end
9 |
10 | function M.general()
11 | vim.keymap.set("n", "n", "nzzzv")
12 | vim.keymap.set("n", "N", "Nzzzv")
13 | -- vim.keymap.set("n", "G", "Gzzzv")
14 | vim.keymap.set("n", "J", "mzJ`z")
15 | vim.keymap.set("i", ",", ",u")
16 | vim.keymap.set("i", ".", ".u")
17 | vim.keymap.set("i", "!", "!u")
18 | vim.keymap.set("i", "?", "?u")
19 | vim.keymap.set("n", "ll", ":luafile %")
20 | vim.keymap.set("v", "J", ":m .+1gv=gv", { silent = true })
21 | vim.keymap.set("v", "K", ":m .-2gv=gv", { silent = true })
22 | vim.keymap.set("n", "s", ":vsplit", { silent = true, desc = "Vertical split" })
23 | vim.keymap.set("n", "q", M.better_close, { desc = "Close buffer" })
24 | vim.keymap.set("n", "Q", ":%bd|e#", { desc = "Close all other buffers" })
25 | vim.cmd [[nnoremap ]]
26 | vim.keymap.set("n", "", ":b#", { silent = true, desc = "Switch buffers" })
27 | vim.keymap.set("n", "[q", ":cnext", { silent = true, desc = "Next item in quickfix list" })
28 | vim.keymap.set("n", "]q", ":cprev", { silent = true, desc = "Previous item in quickfix list" })
29 | vim.keymap.set("n", "", [[{-> v:hlsearch ? ":nohl\" : "\"}()]], { silent = true, expr = true })
30 | vim.keymap.set(
31 | { "n", "x", "o" },
32 | "n",
33 | '"Nn"[v:searchforward]',
34 | { expr = true, desc = "Better forward N behaviour" }
35 | )
36 | vim.keymap.set(
37 | { "n", "x", "o" },
38 | "N",
39 | '"nN"[v:searchforward]',
40 | { expr = true, desc = "Better backward N behaviour" }
41 | )
42 | vim.keymap.set("v", "<", "", ">gv", { desc = "Indent current selection" })
44 | vim.keymap.set("n", "/", "ms/", { desc = "Keeps jumplist after forward searching" })
45 | vim.keymap.set("n", "?", "ms?", { desc = "Keeps jumplist after backward searching" })
46 | vim.keymap.set("n", "Q", "", { desc = "Remove annoying exmode" })
47 | vim.keymap.set("n", "q:", "", { desc = "Remove annoying exmode" })
48 | vim.keymap.set("n", "c", '"_c')
49 | vim.keymap.set("n", "C", '"_C')
50 | vim.keymap.set("n", "s", '"_s')
51 | vim.keymap.set("n", "S", '"_S')
52 | vim.keymap.set("n", "c_", '"_c^')
53 | vim.keymap.set("n", "d_", '"_d^')
54 | vim.keymap.set("n", "", ":vertical resize +2")
55 | vim.keymap.set("n", "", ":resize +2")
56 | vim.keymap.set("n", "", ":resize -2")
57 | vim.keymap.set("n", "", ":vertical resize -2")
58 | vim.keymap.set("v", "p", "P")
59 | -- vim.keymap.set("n", "gx", function()
60 | -- vim.fn.jobstart({ "xdg-open", vim.fn.expand("", nil, nil) }, { detach = true })
61 | -- end, {})
62 | vim.keymap.set("n", "w", [[call feedkeys("\c-w>")]], { silent = true })
63 | vim.keymap.set("n", "s", ":luafile %")
64 | end
65 |
66 | function M.movements()
67 | vim.keymap.set("n", "", "")
68 | vim.keymap.set("n", "", "")
69 | vim.keymap.set("n", "", "")
70 | vim.keymap.set("n", "", "")
71 | vim.keymap.set({ "i", "v" }, "", "")
72 | vim.keymap.set({ "i", "v" }, "", "