diff --git a/.gitignore b/.gitignore
index 005b535b606..8a192cab54d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,3 @@ test.sh
nvim
spell/
-lazy-lock.json
diff --git a/.tmux.conf b/.tmux.conf
new file mode 100644
index 00000000000..a274275c881
--- /dev/null
+++ b/.tmux.conf
@@ -0,0 +1,27 @@
+bind-key -r f run-shell "tmux neww ~/repo/config/tmux-s"
+
+set-option -g prefix C-Space
+unbind C-b
+bind C-Space send-prefix
+
+setw -g mode-keys vi
+bind -T copy-mode-vi v send -X begin-selection
+bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
+bind P paste-buffer
+bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
+
+set -g mouse on
+set -g base-index 1
+
+set -g status-style 'fg=red'
+set -g status-left ' #S '
+set -g status-left-length 20
+set -g status-right ''
+set -g status-bg black
+
+setw -g window-status-current-style 'fg=black bg=red'
+setw -g window-status-current-format ' #I #W #F '
+setw -g window-status-style 'fg=red bg=black'
+setw -g window-status-format ' #I #[fg=white]#W #[fg=yellow]#F '
+setw -g window-status-bell-style 'fg=yellow bg=red bold'
+
diff --git a/comment-toggle.lua b/comment-toggle.lua
new file mode 100644
index 00000000000..8c00c90d2ab
--- /dev/null
+++ b/comment-toggle.lua
@@ -0,0 +1,58 @@
+-- Function to detect if a line contains JSX/TSX content
+local function is_jsx_line(line)
+ -- Check for JSX patterns: , or JSX expressions
+ return line:match('<[/%a]') ~= nil
+ or line:match('/>%s*$') ~= nil
+ or line:match('^%s*{') ~= nil -- Lines starting with { (JSX expressions)
+end
+
+-- Function to comment out line(s)
+local function comment_line()
+ local count = vim.v.count + 1
+ local start_line = vim.fn.line '.' -- Get current line number
+ local filetype = vim.bo.filetype
+
+ -- Check only the first line to determine comment style for all lines
+ local first_line = vim.fn.getline(start_line)
+
+ -- Detect if it's a JSX comment or regular comment on first line
+ local is_jsx_commented = first_line:match '^%s*{/%*' ~= nil
+ local is_regular_commented = first_line:match '^%s*//' ~= nil
+
+ -- Determine comment style to use based on first line
+ local use_jsx_comment = false
+ if not is_jsx_commented and not is_regular_commented then
+ -- When commenting: check if first line is JSX content
+ use_jsx_comment = (filetype == 'typescriptreact' or filetype == 'javascriptreact') and is_jsx_line(first_line)
+ end
+
+ for i = 0, count - 1 do
+ local line_num = start_line + i
+ local line = vim.fn.getline(line_num)
+ local new_line
+
+ if is_jsx_commented then
+ -- Uncomment JSX: remove {/* and */}
+ new_line = line:gsub('^(%s*){/%*%s*(.-)%s*%*/}', '%1%2')
+ elseif is_regular_commented then
+ -- Uncomment: remove leading whitespace, //, and optional space after //
+ new_line = line:gsub('^%s*//%s?', '')
+ else
+ -- Comment: use style determined from first line
+ if use_jsx_comment then
+ -- JSX comment: {/* ... */}
+ new_line = line:gsub('^(%s*)(.*)', '%1{/* %2 */}')
+ else
+ -- Regular comment: //
+ new_line = '// ' .. line
+ end
+ end
+
+ vim.fn.setline(line_num, new_line)
+ end
+
+ -- Move cursor down by count lines
+ vim.cmd('normal! ' .. count .. 'j')
+end
+
+vim.keymap.set('n', 'c', comment_line, { desc = 'Toggle line comment(s)' })
diff --git a/init.lua b/init.lua
index cbf9ff65d67..f04892f56a9 100644
--- a/init.lua
+++ b/init.lua
@@ -1,91 +1,3 @@
---[[
-
-=====================================================================
-==================== READ THIS BEFORE CONTINUING ====================
-=====================================================================
-======== .-----. ========
-======== .----------------------. | === | ========
-======== |.-""""""""""""""""""-.| |-----| ========
-======== || || | === | ========
-======== || KICKSTART.NVIM || |-----| ========
-======== || || | === | ========
-======== || || |-----| ========
-======== ||:Tutor || |:::::| ========
-======== |'-..................-'| |____o| ========
-======== `"")----------------(""` ___________ ========
-======== /::::::::::| |::::::::::\ \ no mouse \ ========
-======== /:::========| |==hjkl==:::\ \ required \ ========
-======== '""""""""""""' '""""""""""""' '""""""""""' ========
-======== ========
-=====================================================================
-=====================================================================
-
-What is Kickstart?
-
- Kickstart.nvim is *not* a distribution.
-
- Kickstart.nvim is a starting point for your own configuration.
- The goal is that you can read every line of code, top-to-bottom, understand
- what your configuration is doing, and modify it to suit your needs.
-
- Once you've done that, you can start exploring, configuring and tinkering to
- make Neovim your own! That might mean leaving Kickstart just the way it is for a while
- or immediately breaking it into modular pieces. It's up to you!
-
- If you don't know anything about Lua, I recommend taking some time to read through
- a guide. One possible example which will only take 10-15 minutes:
- - https://learnxinyminutes.com/docs/lua/
-
- After understanding a bit more about Lua, you can use `:help lua-guide` as a
- reference for how Neovim integrates Lua.
- - :help lua-guide
- - (or HTML version): https://neovim.io/doc/user/lua-guide.html
-
-Kickstart Guide:
-
- TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
-
- If you don't know what this means, type the following:
- -
- - :
- - Tutor
- -
-
- (If you already know the Neovim basics, you can skip this step.)
-
- Once you've completed that, you can continue working through **AND READING** the rest
- of the kickstart init.lua.
-
- Next, run AND READ `:help`.
- This will open up a help window with some basic information
- about reading, navigating and searching the builtin help documentation.
-
- This should be the first place you go to look when you're stuck or confused
- with something. It's one of my favorite Neovim features.
-
- MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation,
- which is very useful when you're not exactly sure of what you're looking for.
-
- I have left several `:help X` comments throughout the init.lua
- These are hints about where to find more information about the relevant settings,
- plugins or Neovim features used in Kickstart.
-
- NOTE: Look for lines like this
-
- Throughout the file. These are for you, the reader, to help you understand what is happening.
- Feel free to delete them once you know what you're doing, but they should serve as a guide
- for when you are first encountering a few different constructs in your Neovim config.
-
-If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
-
-I hope you enjoy your Neovim journey,
-- TJ
-
-P.S. You can delete this when you're done too. It's your config now! :)
---]]
-
--- Set as the leader key
--- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
@@ -93,38 +5,18 @@ vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
--- [[ Setting options ]]
--- See `:help vim.opt`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
--- Make line numbers default
vim.opt.number = true
--- You can also add relative line numbers, to help with jumping.
--- Experiment for yourself to see if you like it!
--- vim.opt.relativenumber = true
-
--- Enable mouse mode, can be useful for resizing splits for example!
-vim.opt.mouse = 'a'
+vim.opt.relativenumber = true
-- Don't show the mode, since it's already in the status line
vim.opt.showmode = false
-
--- Sync clipboard between OS and Neovim.
--- Schedule the setting after `UiEnter` because it can increase startup-time.
--- Remove this option if you want your OS clipboard to remain independent.
--- See `:help 'clipboard'`
-vim.schedule(function()
- vim.opt.clipboard = 'unnamedplus'
-end)
-
--- Enable break indent
vim.opt.breakindent = true
-- Save undo history
vim.opt.undofile = true
-
--- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true
vim.opt.smartcase = true
@@ -141,12 +33,6 @@ vim.opt.timeoutlen = 300
vim.opt.splitright = true
vim.opt.splitbelow = true
--- Sets how neovim will display certain whitespace characters in the editor.
--- See `:help 'list'`
--- and `:help 'listchars'`
-vim.opt.list = true
-vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-
-- Preview substitutions live, as you type!
vim.opt.inccommand = 'split'
@@ -161,8 +47,14 @@ vim.opt.scrolloff = 10
-- See `:help 'confirm'`
vim.opt.confirm = true
--- [[ Basic Keymaps ]]
--- See `:help vim.keymap.set()`
+-- NOTE: My personal key bining
+vim.keymap.set('v', 'l', "yoconsole.log('pa', pa);", { desc = 'log selected value' })
+vim.keymap.set('n', 'e', ':e.', { desc = 'Open file three' })
+
+-- Load comment toggle functionality
+dofile(vim.fn.expand '~/repo/config/comment-toggle.lua')
+
+-- NOTE: My personal key bining END
-- Clear highlights on search when pressing in normal mode
-- See `:help hlsearch`
@@ -170,6 +62,14 @@ vim.keymap.set('n', '', 'nohlsearch')
-- Diagnostic keymaps
vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
+vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Show [D]iagnostic in floating window' })
+
+-- Auto-show diagnostic in floating window on cursor hold
+vim.api.nvim_create_autocmd('CursorHold', {
+ callback = function()
+ vim.diagnostic.open_float(nil, { focus = false, scope = 'cursor' })
+ end,
+})
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press , which
@@ -179,20 +79,14 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn
-- or just use to exit terminal mode
vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' })
--- TIP: Disable arrow keys in normal mode
--- vim.keymap.set('n', '', 'echo "Use h to move!!"')
--- vim.keymap.set('n', '', 'echo "Use l to move!!"')
--- vim.keymap.set('n', '', 'echo "Use k to move!!"')
--- vim.keymap.set('n', '', 'echo "Use j to move!!"')
-
-- Keybinds to make split navigation easier.
-- Use CTRL+ to switch between windows
--
-- See `:help wincmd` for a list of all window commands
-vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' })
-vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' })
-vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' })
-vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' })
+--vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' })
+--vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' })
+--vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' })
+--vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' })
-- NOTE: Some terminals have coliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "", "H", { desc = "Move window to the left" })
@@ -203,9 +97,6 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
--- Highlight when yanking (copying) text
--- Try it with `yap` in normal mode
--- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
@@ -404,12 +295,27 @@ require('lazy').setup({
-- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()`
--
- -- defaults = {
- -- mappings = {
- -- i = { [''] = 'to_fuzzy_refine' },
- -- },
- -- },
- -- pickers = {}
+ defaults = {
+ -- mappings = {
+ -- i = { [''] = 'to_fuzzy_refine' },
+ -- },
+ file_ignore_patterns = { '.git/' },
+ },
+ pickers = {
+ find_files = {
+ hidden = true,
+ },
+ live_grep = {
+ additional_args = function()
+ return { '--hidden' }
+ end,
+ },
+ grep_string = {
+ additional_args = function()
+ return { '--hidden' }
+ end,
+ },
+ },
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
@@ -426,6 +332,7 @@ require('lazy').setup({
vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' })
+ vim.keymap.set('n', 'st', builtin.git_files, { desc = '[S]earch [G]it files' })
vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
@@ -490,31 +397,6 @@ require('lazy').setup({
'hrsh7th/cmp-nvim-lsp',
},
config = function()
- -- Brief aside: **What is LSP?**
- --
- -- LSP is an initialism you've probably heard, but might not understand what it is.
- --
- -- LSP stands for Language Server Protocol. It's a protocol that helps editors
- -- and language tooling communicate in a standardized fashion.
- --
- -- In general, you have a "server" which is some tool built to understand a particular
- -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
- -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
- -- processes that communicate with some "client" - in this case, Neovim!
- --
- -- LSP provides Neovim with features like:
- -- - Go to definition
- -- - Find references
- -- - Autocompletion
- -- - Symbol Search
- -- - and more!
- --
- -- Thus, Language Servers are external tools that must be installed separately from
- -- Neovim. This is where `mason` and related plugins come into play.
- --
- -- If you're wondering about lsp vs treesitter, you can check out the wonderfully
- -- and elegantly composed help section, `:help lsp-vs-treesitter`
-
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
@@ -532,41 +414,14 @@ require('lazy').setup({
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
- -- Jump to the definition of the word under your cursor.
- -- This is where a variable was first declared, or where a function is defined, etc.
- -- To jump back, press .
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
-
- -- Find references for the word under your cursor.
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
-
- -- Jump to the implementation of the word under your cursor.
- -- Useful when your language has ways of declaring types without an actual implementation.
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
-
- -- Jump to the type of the word under your cursor.
- -- Useful when you're not sure what type a variable is and you want to see
- -- the definition of its *type*, not where it was *defined*.
map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
-
- -- Fuzzy find all the symbols in your current document.
- -- Symbols are things like variables, functions, types, etc.
map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
-
- -- Fuzzy find all the symbols in your current workspace.
- -- Similar to document symbols, except searches over your entire project.
map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-
- -- Rename the variable under your cursor.
- -- Most Language Servers support renaming across files, etc.
map('rn', vim.lsp.buf.rename, '[R]e[n]ame')
-
- -- Execute a code action, usually your cursor needs to be on top of an error
- -- or a suggestion from your LSP for this to activate.
map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
-
- -- WARN: This is not Goto Definition, this is Goto Declaration.
- -- For example, in C this would take you to the header.
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
@@ -641,13 +496,12 @@ require('lazy').setup({
source = 'if_many',
spacing = 2,
format = function(diagnostic)
- local diagnostic_message = {
- [vim.diagnostic.severity.ERROR] = diagnostic.message,
- [vim.diagnostic.severity.WARN] = diagnostic.message,
- [vim.diagnostic.severity.INFO] = diagnostic.message,
- [vim.diagnostic.severity.HINT] = diagnostic.message,
- }
- return diagnostic_message[diagnostic.severity]
+ local max_width = 80
+ local message = diagnostic.message
+ if #message > max_width then
+ message = message:sub(1, max_width) .. '...'
+ end
+ return message
end,
},
}
@@ -669,19 +523,6 @@ require('lazy').setup({
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
- -- clangd = {},
- -- gopls = {},
- -- pyright = {},
- -- rust_analyzer = {},
- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
- --
- -- Some languages (like typescript) have entire language plugins that can be useful:
- -- https://github.com/pmizio/typescript-tools.nvim
- --
- -- But for many setups, the LSP (`ts_ls`) will work just fine
- -- ts_ls = {},
- --
-
lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
@@ -766,11 +607,10 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
- -- Conform can also run multiple formatters sequentially
- -- python = { "isort", "black" },
- --
- -- You can use 'stop_after_first' to run the first available formatter from the list
- -- javascript = { "prettierd", "prettier", stop_after_first = true },
+ javascript = { 'prettier' },
+ typescript = { 'prettier' },
+ tsx = { 'prettier' },
+ typescriptreact = { 'prettier' },
},
},
},
@@ -843,7 +683,7 @@ require('lazy').setup({
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
- [''] = cmp.mapping.confirm { select = true },
+ [''] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
diff --git a/tmux-s b/tmux-s
new file mode 100755
index 00000000000..6e166236f16
--- /dev/null
+++ b/tmux-s
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+TS_SEARCH_PATHS=("$HOME/repo:1" "$HOME/repo/astro:2" "$HOME/repo/tripletex-frontend/scripts/migrate-repo/:2")
+TS_MAX_DEPTH=2
+
+find_dirs() {
+ # list TMUX sessions
+ if [[ -n "${TMUX}" ]]; then
+ current_session=$(tmux display-message -p '#S')
+ tmux list-sessions -F "[TMUX] #{session_name}" 2>/dev/null | grep -vFx "[TMUX] $current_session"
+ else
+ tmux list-sessions -F "[TMUX] #{session_name}" 2>/dev/null
+ fi
+
+ # if the path ends with :number, it will search for directories with a max depth of number ;)
+ # if there is no number, it will search for directories with a max depth defined by TS_MAX_DEPTH or 1 if not set
+ for entry in "${TS_SEARCH_PATHS[@]}"; do
+ # Check if entry as :number as suffix then adapt the maxdepth parameter
+ if [[ "$entry" =~ ^([^:]+):([0-9]+)$ ]]; then
+ path="${BASH_REMATCH[1]}"
+ depth="${BASH_REMATCH[2]}"
+ else
+ path="$entry"
+ fi
+
+ depth="${depth:-${TS_MAX_DEPTH:-1}}"
+
+ [[ -d "$path" ]] && find "$path" -mindepth 1 -maxdepth "$depth" \( -path '*/.git' -o -path '*/node_modules' \) -prune -o -type d -print | sed "s|^$HOME/||"
+ done
+}
+
+has_session() {
+ tmux list-sessions | grep -q "^$1:"
+}
+
+switch_to() {
+ if [[ -z $TMUX ]]; then
+ log "attaching to session $1"
+ tmux attach-session -t "$1"
+ else
+ log "switching to session $1"
+ tmux switch-client -t "$1"
+ fi
+}
+
+selected=$(find_dirs | fzf)
+
+if [[ "$selected" =~ ^\[TMUX\]\ (.+)$ ]]; then
+ selected="${BASH_REMATCH[1]}"
+fi
+
+selected_name=$(basename "$selected")
+
+if ! has_session "$selected_name"; then
+ cd "$HOME/$selected"
+ tmux new-session -ds "$selected_name" -c "$HOME/$selected"
+
+ tmux rename-window -t "$selected_name":1 "Code"
+ tmux send-keys -t "$selected_name":1 "nvim" C-m
+ tmux new-window -t "$selected_name":2 -n "Server"
+ tmux new-window -t "$selected_name":3 -n "Claude"
+ tmux new-window -t "$selected_name":4 -n "Whatever"
+fi
+
+switch_to "$selected_name"
+
+