Skip to content

Commit d350f91

Browse files
committed
Inserting zoxide
1 parent 439f26e commit d350f91

File tree

4 files changed

+126
-5
lines changed

4 files changed

+126
-5
lines changed

init.lua

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ require('lazy').setup({
279279
},
280280
},
281281
},
282-
282+
{ 'jvgrootveld/telescope-zoxide', opts = {} },
283283
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
284284
--
285285
-- This is often very useful to both group configuration, as well as handle
@@ -403,6 +403,7 @@ require('lazy').setup({
403403

404404
-- [[ Configure Telescope ]]
405405
-- See `:help telescope` and `:help telescope.setup()`
406+
local z_utils = require 'telescope._extensions.zoxide.utils'
406407
require('telescope').setup {
407408
-- You can put your default mappings / updates / etc. in here
408409
-- All the info you're looking for is in `:help telescope.setup()`
@@ -422,11 +423,42 @@ require('lazy').setup({
422423
auto_quoting = true,
423424
theme = 'dropdown',
424425
},
426+
['zoxide'] = {
427+
prompt_title = '[ Zoxide List ]',
428+
429+
-- Zoxide list command with score
430+
list_command = 'zoxide query -ls',
431+
mappings = {
432+
default = {
433+
action = function(selection)
434+
vim.cmd.cd(selection.path)
435+
end,
436+
after_action = function(selection)
437+
vim.notify('Directory changed to ' .. selection.path)
438+
end,
439+
},
440+
['<C-s>'] = { action = z_utils.create_basic_command 'split' },
441+
['<C-v>'] = { action = z_utils.create_basic_command 'vsplit' },
442+
['<C-e>'] = { action = z_utils.create_basic_command 'edit' },
443+
['<C-f>'] = {
444+
keepinsert = true,
445+
action = function(selection)
446+
builtin.find_files { cwd = selection.path }
447+
end,
448+
},
449+
['<C-t>'] = {
450+
action = function(selection)
451+
vim.cmd.tcd(selection.path)
452+
end,
453+
},
454+
},
455+
},
425456
},
426457
}
427458

428459
-- Enable Telescope extensions if they are installed
429460
pcall(require('telescope').load_extension, 'fzf')
461+
pcall(require('telescope').load_extension, 'zoxide')
430462
pcall(require('telescope').load_extension, 'ui-select')
431463

432464
-- See `:help telescope.builtin`
@@ -740,8 +772,8 @@ require('lazy').setup({
740772
end,
741773
formatters_by_ft = {
742774
cmake = { 'cmakelang' },
743-
cpp = { 'clang_format' },
744-
json = { 'clang_format' },
775+
cpp = { 'clang-format' },
776+
json = { 'clang-format' },
745777
lua = { 'stylua' },
746778
-- Conform can also run multiple formatters sequentially
747779
python = { 'isort' },
@@ -879,7 +911,7 @@ require('lazy').setup({
879911
-- Load the colorscheme here.
880912
-- Like many other themes, this one has different styles, and you could load
881913
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
882-
vim.cmd.colorscheme 'wildcharm'
914+
vim.cmd.colorscheme 'retrobox'
883915

884916
-- You can configure highlights by doing something like:
885917
vim.cmd.hi 'Comment gui=none'
@@ -971,7 +1003,7 @@ require('lazy').setup({
9711003
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
9721004
--
9731005
-- require 'kickstart.plugins.debug',
974-
-- require 'kickstart.plugins.indent_line',
1006+
require 'kickstart.plugins.indent_line',
9751007
-- require 'kickstart.plugins.lint',
9761008
-- require 'kickstart.plugins.autopairs',
9771009
-- require 'kickstart.plugins.neo-tree',
@@ -1042,3 +1074,4 @@ require('lazy').setup({
10421074

10431075
-- The line beneath this is called `modeline`. See `:help modeline`
10441076
-- vim: ts=2 sts=2 sw=2 et
1077+
require 'custom/keymap'

lua/custom/autocommands.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- [[ Basic Autocommands ]]
2+
-- See `:help lua-guide-autocommands`
3+
4+
-- Highlight when yanking (copying) text
5+
-- Try it with `yap` in normal mode
6+
-- See `:help vim.highlight.on_yank()`
7+
vim.api.nvim_create_autocmd('TextYankPost', {
8+
desc = 'Highlight when yanking (copying) text',
9+
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
10+
callback = function()
11+
vim.highlight.on_yank()
12+
end,
13+
})

lua/custom/keymap.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- [[ Basic Keymaps ]]
2+
-- See `:help vim.keymap.set()`
3+
4+
-- Set highlight on search, but clear on pressing <Esc> in normal mode
5+
vim.keymap.set('n', '<leader>fa', '<cmd>lua vim.lsp.buf.format()<CR>')
6+
vim.keymap.set('n', '<leader>mt', '<cmd>NvimTreeFocus<CR>')
7+
vim.keymap.set('n', '<C-o>', '<cmd>ClangdSwitchSourceHeader<CR>')
8+
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
9+
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
10+
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
11+
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
12+
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
13+
vim.keymap.set('n', '<leader>z', require('telescope').extensions.zoxide.list)
14+
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
15+
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
16+
-- is not what someone will guess without a bit more experience.
17+
--
18+
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
19+
-- or just use <C-\><C-n> to exit terminal mode
20+
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
21+
22+
-- TIP: Disable arrow keys in normal mode
23+
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
24+
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
25+
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
26+
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
27+
28+
-- Keybinds to make split navigation easier.
29+
-- Use CTRL+<hjkl> to switch between windows
30+
--
31+
-- See `:help wincmd` for a list of all window commands
32+
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
33+
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
34+
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
35+
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })

lua/custom/vim_options.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
vim.g.mapleader = ' '
2+
vim.g.maplocalleader = ' '
3+
vim.g.loaded_netrw = 1
4+
vim.g.loaded_netrwPlugin = 1
5+
vim.g.have_nerd_font = true
6+
vim.opt.tabstop = 2
7+
vim.opt.shiftwidth = 2
8+
vim.opt.encoding = 'UTF-8'
9+
vim.opt.wrap = false
10+
vim.opt.termguicolors = true
11+
vim.opt.autoindent = true
12+
vim.api.nvim_create_augroup('neotree', {})
13+
vim.api.nvim_create_autocmd('UiEnter', {
14+
desc = 'Open Neotree automatically',
15+
group = 'neotree',
16+
callback = function()
17+
if vim.fn.argc() == 0 then
18+
vim.cmd 'NvimTreeToggle'
19+
end
20+
end,
21+
})
22+
vim.opt.number = true
23+
vim.opt.mouse = 'a'
24+
vim.opt.showmode = false
25+
vim.opt.clipboard = 'unnamedplus'
26+
vim.opt.breakindent = true
27+
vim.opt.undofile = true
28+
vim.opt.ignorecase = true
29+
vim.opt.smartcase = true
30+
vim.opt.signcolumn = 'yes'
31+
vim.opt.updatetime = 250
32+
vim.opt.timeoutlen = 300
33+
vim.opt.splitright = true
34+
vim.opt.splitbelow = true
35+
vim.opt.list = true
36+
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
37+
vim.opt.inccommand = 'split'
38+
vim.opt.cursorline = true
39+
vim.opt.scrolloff = 10
40+
vim.opt.hlsearch = true

0 commit comments

Comments
 (0)