fixup
This commit is contained in:
parent
ca9bea87d8
commit
a95d34bfb6
94
init.lua
94
init.lua
|
|
@ -1,89 +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:
|
|
||||||
- <escape key>
|
|
||||||
- :
|
|
||||||
- Tutor
|
|
||||||
- <enter key>
|
|
||||||
|
|
||||||
(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 "<space>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 <space> as the leader key
|
-- Set <space> as the leader key
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
||||||
|
|
@ -91,7 +5,7 @@ vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.opt`
|
-- See `:help vim.opt`
|
||||||
|
|
@ -169,12 +83,6 @@ vim.g.mapleader = ' '
|
||||||
|
|
||||||
vim.opt.swapfile = false
|
vim.opt.swapfile = false
|
||||||
|
|
||||||
-- Navigate vim panes better
|
|
||||||
vim.keymap.set('n', '<c-k>', ':wincmd k<CR>')
|
|
||||||
vim.keymap.set('n', '<c-j>', ':wincmd j<CR>')
|
|
||||||
vim.keymap.set('n', '<c-h>', ':wincmd h<CR>')
|
|
||||||
vim.keymap.set('n', '<c-l>', ':wincmd l<CR>')
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>h', ':nohlsearch<CR>')
|
vim.keymap.set('n', '<leader>h', ':nohlsearch<CR>')
|
||||||
vim.wo.number = true
|
vim.wo.number = true
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,15 @@ return {
|
||||||
event = 'VeryLazy',
|
event = 'VeryLazy',
|
||||||
---@type Flash.Config
|
---@type Flash.Config
|
||||||
opts = {
|
opts = {
|
||||||
jump = {
|
modes = {
|
||||||
pos = 'end',
|
char = {
|
||||||
|
enabled = false,
|
||||||
|
jump_labels = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
keys = {
|
keys = {
|
||||||
{ "<space><space>", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
|
{ "/", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
return {
|
return {
|
||||||
'ThePrimeagen/harpoon',
|
-- 'ThePrimeagen/harpoon',
|
||||||
branch = 'harpoon2',
|
-- branch = 'harpoon2',
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
-- dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
init = function()
|
-- init = function()
|
||||||
local harpoon = require 'harpoon'
|
-- local harpoon = require 'harpoon'
|
||||||
|
--
|
||||||
harpoon:setup()
|
-- harpoon:setup()
|
||||||
vim.keymap.set('n', '<leader>a', function()
|
-- vim.keymap.set('n', '<leader>a', function()
|
||||||
harpoon:list():add()
|
-- harpoon:list():add()
|
||||||
end)
|
-- end)
|
||||||
vim.keymap.set('n', '<C-e>', function()
|
-- vim.keymap.set('n', '<C-e>', function()
|
||||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
-- harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||||
end)
|
-- end)
|
||||||
|
--
|
||||||
vim.keymap.set('n', '<C-h>', function()
|
-- vim.keymap.set('n', '<C-h>', function()
|
||||||
harpoon:list():select(1)
|
-- harpoon:list():select(1)
|
||||||
end)
|
-- end)
|
||||||
vim.keymap.set('n', '<C-t>', function()
|
-- vim.keymap.set('n', '<C-j>', function()
|
||||||
harpoon:list():select(2)
|
-- harpoon:list():select(2)
|
||||||
end)
|
-- end)
|
||||||
vim.keymap.set('n', '<C-n>', function()
|
-- vim.keymap.set('n', '<C-k>', function()
|
||||||
harpoon:list():select(3)
|
-- harpoon:list():select(3)
|
||||||
end)
|
-- end)
|
||||||
vim.keymap.set('n', '<C-s>', function()
|
-- vim.keymap.set('n', '<C-l>', function()
|
||||||
harpoon:list():select(4)
|
-- harpoon:list():select(4)
|
||||||
end)
|
-- end)
|
||||||
|
--
|
||||||
-- Toggle previous & next buffers stored within Harpoon list
|
-- -- Toggle previous & next buffers stored within Harpoon list
|
||||||
vim.keymap.set('n', '<C-S-P>', function()
|
-- vim.keymap.set('n', '<C-S-P>', function()
|
||||||
harpoon:list():prev()
|
-- harpoon:list():prev()
|
||||||
end)
|
-- end)
|
||||||
vim.keymap.set('n', '<C-S-N>', function()
|
-- vim.keymap.set('n', '<C-S-N>', function()
|
||||||
harpoon:list():next()
|
-- harpoon:list():next()
|
||||||
end)
|
-- end)
|
||||||
end,
|
-- end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
return {
|
return {
|
||||||
'christoomey/vim-tmux-navigator',
|
'christoomey/vim-tmux-navigator',
|
||||||
cmd = {
|
cmd = {
|
||||||
|
'TmuxNavigateLeft',
|
||||||
'TmuxNavigateDown',
|
'TmuxNavigateDown',
|
||||||
'TmuxNavigateUp',
|
'TmuxNavigateUp',
|
||||||
'TmuxNavigateRight',
|
'TmuxNavigateRight',
|
||||||
|
|
@ -8,6 +9,7 @@ return {
|
||||||
'TmuxNavigatorProcessList',
|
'TmuxNavigatorProcessList',
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
|
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
|
||||||
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
|
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
|
||||||
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
|
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
|
||||||
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
|
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
-- Function to convert to uppercase and set a mark
|
||||||
|
vim.api.nvim_create_user_command('SetGlobalMark', function()
|
||||||
|
local ok, char = pcall(vim.fn.getcharstr)
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Convert lowercase to uppercase
|
||||||
|
if char:match '[a-z]' then
|
||||||
|
char = char:upper()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd('normal! m' .. char)
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
-- Function to convert to uppercase and jump to a mark
|
||||||
|
vim.api.nvim_create_user_command('JumpToGlobalMark', function()
|
||||||
|
local ok, char = pcall(vim.fn.getcharstr)
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Convert lowercase to uppercase
|
||||||
|
if char:match '[a-z]' then
|
||||||
|
char = char:upper()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd("normal! '" .. char)
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
-- Map your preferred key combinations to the functions
|
||||||
|
vim.keymap.set('n', '<C-m>', ':SetGlobalMark<CR>', { noremap = true })
|
||||||
|
vim.keymap.set('n', '<C-s>', ':JumpToGlobalMark<CR>', { noremap = true })
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
-- Add this to your init.lua or create a file in your lua director-- Add this to your init.lua or create a file in your lua directory
|
|
||||||
-- and require it from your init.lua
|
|
||||||
|
|
||||||
-- State variables
|
|
||||||
local selection_active = false
|
|
||||||
local selected_symbol = nil
|
|
||||||
local initial_pos = nil
|
|
||||||
local visual_mode_active = false
|
|
||||||
|
|
||||||
-- Function to select the current symbol and handle iteration
|
|
||||||
function select_and_iterate_symbol()
|
|
||||||
-- Exit visual mode first if active to prevent issues
|
|
||||||
if visual_mode_active then
|
|
||||||
vim.cmd 'normal! <Esc>'
|
|
||||||
visual_mode_active = false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If selection is not active, start a new selection
|
|
||||||
if not selection_active then
|
|
||||||
-- Get the current symbol under cursor (includes special characters)
|
|
||||||
local current_symbol = vim.fn.expand '<cword>'
|
|
||||||
|
|
||||||
-- Check if there's actually a symbol under the cursor
|
|
||||||
if current_symbol == '' then
|
|
||||||
vim.api.nvim_echo({ { 'No symbol under cursor', 'ErrorMsg' } }, false, {})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Store the symbol for later use (exact match)
|
|
||||||
selected_symbol = current_symbol
|
|
||||||
|
|
||||||
-- Store the initial position before moving
|
|
||||||
initial_pos = vim.fn.getpos '.'
|
|
||||||
|
|
||||||
-- Set up a search pattern for the exact symbol
|
|
||||||
vim.fn.setreg('/', '\\V\\<' .. vim.fn.escape(selected_symbol, '\\') .. '\\>')
|
|
||||||
|
|
||||||
-- Enter visual mode and select the current symbol
|
|
||||||
vim.cmd 'normal! viw'
|
|
||||||
visual_mode_active = true
|
|
||||||
|
|
||||||
-- Set state to active
|
|
||||||
selection_active = true
|
|
||||||
|
|
||||||
-- Echo instructions
|
|
||||||
vim.api.nvim_echo({ { 'Selected symbol: ' .. current_symbol .. '. Press Ctrl-R again to iterate, <CR> to edit all.', 'Normal' } }, false, {})
|
|
||||||
else
|
|
||||||
-- Selection is active, find the next occurrence
|
|
||||||
|
|
||||||
-- Search for the next occurrence (exact match with very nomagic mode \V)
|
|
||||||
local search_pattern = '\\V\\<' .. vim.fn.escape(selected_symbol, '\\') .. '\\>'
|
|
||||||
local found = vim.fn.search(search_pattern, 'W')
|
|
||||||
|
|
||||||
if found == 0 then
|
|
||||||
-- If no more occurrences, wrap around to the beginning
|
|
||||||
vim.cmd 'normal! gg'
|
|
||||||
found = vim.fn.search(search_pattern, 'W')
|
|
||||||
|
|
||||||
-- If still no occurrences or we've come full circle
|
|
||||||
if found == 0 or vim.fn.line '.' == vim.fn.line(initial_pos[2]) and vim.fn.col '.' == vim.fn.col(initial_pos[3]) then
|
|
||||||
vim.api.nvim_echo({ { 'No more occurrences found.', 'Normal' } }, false, {})
|
|
||||||
-- Reset state
|
|
||||||
selection_active = false
|
|
||||||
selected_symbol = nil
|
|
||||||
initial_pos = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Select the symbol
|
|
||||||
vim.cmd 'normal! viw'
|
|
||||||
visual_mode_active = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Function to edit all occurrences
|
|
||||||
function edit_all_occurrences()
|
|
||||||
-- If no symbol is selected, do nothing
|
|
||||||
if not selection_active then
|
|
||||||
vim.api.nvim_echo({ { 'No symbol selected. Use Ctrl-R first.', 'ErrorMsg' } }, false, {})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Exit visual mode
|
|
||||||
vim.cmd 'normal! <Esc>'
|
|
||||||
visual_mode_active = false
|
|
||||||
|
|
||||||
-- Set up a command to find and replace with very nomagic mode for exact matching
|
|
||||||
local escaped_symbol = vim.fn.escape(selected_symbol, '/\\')
|
|
||||||
local cmd = ':%s/\\V\\<' .. escaped_symbol .. '\\>//gc'
|
|
||||||
|
|
||||||
-- Use feedkeys with 'n' to avoid triggering mappings
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(':' .. cmd, true, false, true), 'n', false)
|
|
||||||
|
|
||||||
-- Reset state
|
|
||||||
selection_active = false
|
|
||||||
selected_symbol = nil
|
|
||||||
initial_pos = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Reset function for cancellation
|
|
||||||
function reset_selection()
|
|
||||||
selection_active = false
|
|
||||||
selected_symbol = nil
|
|
||||||
initial_pos = nil
|
|
||||||
visual_mode_active = false
|
|
||||||
vim.cmd 'normal! <Esc>'
|
|
||||||
vim.api.nvim_echo({ { 'Symbol selection canceled', 'Normal' } }, false, {})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set up key mappings
|
|
||||||
vim.api.nvim_set_keymap('n', '<C-r>', [[<Cmd>lua select_and_iterate_symbol()<CR>]], { noremap = true, silent = true })
|
|
||||||
vim.api.nvim_set_keymap('v', '<C-r>', [[<Cmd>lua select_and_iterate_symbol()<CR>]], { noremap = true, silent = true })
|
|
||||||
vim.api.nvim_set_keymap('v', '<CR>', [[<Cmd>lua edit_all_occurrences()<CR>]], { noremap = true, silent = true })
|
|
||||||
vim.api.nvim_set_keymap('v', '<Esc>', [[<Cmd>lua reset_selection()<CR>]], { noremap = true, silent = true })
|
|
||||||
Loading…
Reference in New Issue