Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e725aeec5d | |||
| 9232a44ef0 | |||
| 66bf2f42aa | |||
| d0d7364994 | |||
| 24f6595139 | |||
| 626c660f54 | |||
| b84f0b775d | |||
| bd53f28e49 | |||
| b01d052770 | |||
| 267fb6aa73 | |||
| 216e06a36d | |||
| 9a023810f4 | |||
| 3a2194f210 | |||
| 7a3532ac07 | |||
| 3a6511c71a | |||
| f1de74680a |
@@ -1,6 +1,10 @@
|
|||||||
# Check Lua Formatting
|
# Check Lua Formatting
|
||||||
name: Check Lua Formatting
|
name: Check Lua Formatting
|
||||||
on: pull_request_target
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stylua-check:
|
stylua-check:
|
||||||
@@ -9,11 +13,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
|
||||||
- name: Stylua Check
|
- name: Stylua Check
|
||||||
uses: JohnnyMorganz/stylua-action@v4
|
uses: JohnnyMorganz/stylua-action@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: latest
|
version: latest
|
||||||
|
|||||||
@@ -61,23 +61,32 @@ Neovim's configurations are located under the following paths, depending on your
|
|||||||
|
|
||||||
#### Recommended Step
|
#### Recommended Step
|
||||||
|
|
||||||
[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo
|
Create your own copy of this repo using GitHub's
|
||||||
so that you have your own copy that you can modify, then install by cloning the
|
["Use this template"](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
|
||||||
fork to your machine using one of the commands below, depending on your OS.
|
button so that you have your own copy that you can modify, then install by
|
||||||
|
cloning your new repo to your machine using one of the commands below,
|
||||||
|
depending on your OS.
|
||||||
|
|
||||||
|
Alternatively, you can [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
|
||||||
|
this repo if you prefer an easy upstream sync path (e.g., keeping your config
|
||||||
|
on a separate branch and fast-forwarding `master` from upstream). See the
|
||||||
|
[discussion in #1740](https://github.com/nvim-lua/kickstart.nvim/issues/1740)
|
||||||
|
for the tradeoffs between the two approaches.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Your fork's URL will be something like this:
|
> Your repo's URL will be something like this:
|
||||||
> `https://github.com/<your_github_username>/kickstart.nvim.git`
|
> `https://github.com/<your_github_username>/kickstart.nvim.git`
|
||||||
|
|
||||||
You likely want to remove `nvim-pack-lock.json` from your fork's `.gitignore`
|
You likely want to remove `nvim-pack-lock.json` from your repo's `.gitignore`
|
||||||
file too - it's ignored in the kickstart repo to make maintenance easier, but
|
file too - it's ignored in the kickstart repo to make maintenance easier, but
|
||||||
it's recommended to track it in version control (see `:help vim.pack-lockfile`).
|
it's recommended to track it in version control (see `:help vim.pack-lockfile`).
|
||||||
|
|
||||||
#### Clone kickstart.nvim
|
#### Clone kickstart.nvim
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> If following the recommended step above (i.e., forking the repo), replace
|
> If following the recommended step above (i.e., creating your own repo from
|
||||||
> `nvim-lua` with `<your_github_username>` in the commands below
|
> the template or fork), replace `nvim-lua` with `<your_github_username>`
|
||||||
|
> in the commands below
|
||||||
|
|
||||||
<details><summary> Linux and Mac </summary>
|
<details><summary> Linux and Mac </summary>
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
|
|||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- SECTION 1: OPTIONS
|
-- SECTION 1: OPTIONS
|
||||||
-- Core Neovim settings, leaders, options, basic keymaps, basic autocmds
|
-- Core Neovim settings, leaders, options
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
do
|
do
|
||||||
-- Enable faster startup by caching compiled Lua modules
|
-- Enable faster startup by caching compiled Lua modules
|
||||||
@@ -110,7 +110,7 @@ do
|
|||||||
vim.o.number = true
|
vim.o.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.o.relativenumber = true
|
vim.o.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.o.mouse = 'a'
|
vim.o.mouse = 'a'
|
||||||
@@ -174,10 +174,16 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- SECTION 2: KEYMAPS
|
-- SECTION 2: KEYMAPS & AUTOCMDS
|
||||||
-- basic keymaps
|
-- basic keymaps, basic autocmds
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
do
|
do
|
||||||
|
|
||||||
|
-- [[ Yuriy Keymaps ]]
|
||||||
|
vim.opt.clipboard = "unnamedplus"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
|
||||||
@@ -251,6 +257,11 @@ do
|
|||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||||
callback = function() vim.hl.on_yank() end,
|
callback = function() vim.hl.on_yank() end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- [[ RPC Server for external control ]]
|
||||||
|
-- Used for changing the theme to light/dark from external tools (e.g. atom.cz)
|
||||||
|
local socket_path = '/tmp/nvim-' .. vim.fn.getpid() .. '.sock'
|
||||||
|
vim.fn.serverstart(socket_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
@@ -385,15 +396,32 @@ do
|
|||||||
vim.pack.add { gh 'folke/tokyonight.nvim' }
|
vim.pack.add { gh 'folke/tokyonight.nvim' }
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
require('tokyonight').setup {
|
require('tokyonight').setup {
|
||||||
|
style = 'moon', -- default dark theme
|
||||||
|
light_style = 'day', -- theme used when background is light
|
||||||
styles = {
|
styles = {
|
||||||
comments = { italic = false }, -- Disable italics in comments
|
comments = { italic = false }, -- Disable italics in comments
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Load the colorscheme here.
|
-- Auto switch based on KDE Plasma system theme
|
||||||
-- Like many other themes, this one has different styles, and you could load
|
local function set_theme()
|
||||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
local handle = io.popen "kreadconfig6 --group 'General' --key 'ColorScheme' 2>/dev/null"
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
if handle == nil then
|
||||||
|
vim.o.background = 'dark'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local result = handle:read '*a'
|
||||||
|
handle:close()
|
||||||
|
if result:match '[Dd]ark' then
|
||||||
|
vim.o.background = 'dark'
|
||||||
|
else
|
||||||
|
vim.o.background = 'light'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_theme()
|
||||||
|
|
||||||
|
-- Uses tokyonight (without suffix) so it respects vim.o.background
|
||||||
|
vim.cmd.colorscheme 'tokyonight'
|
||||||
|
|
||||||
-- Highlight todo, notes, etc in comments
|
-- Highlight todo, notes, etc in comments
|
||||||
vim.pack.add { gh 'folke/todo-comments.nvim' }
|
vim.pack.add { gh 'folke/todo-comments.nvim' }
|
||||||
@@ -494,11 +522,16 @@ do
|
|||||||
-- You can put your default mappings / updates / etc. in here
|
-- You can put your default mappings / updates / etc. in here
|
||||||
-- All the info you're looking for is in `:help telescope.setup()`
|
-- All the info you're looking for is in `:help telescope.setup()`
|
||||||
--
|
--
|
||||||
-- defaults = {
|
defaults = {
|
||||||
-- mappings = {
|
layout_strategy = 'vertical',
|
||||||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
layout_config = {
|
||||||
-- },
|
height = 0.95,
|
||||||
-- },
|
width = 0.95,
|
||||||
|
vertical = {
|
||||||
|
preview_height = 0.5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
-- pickers = {}
|
-- pickers = {}
|
||||||
extensions = {
|
extensions = {
|
||||||
['ui-select'] = { require('telescope.themes').get_dropdown() },
|
['ui-select'] = { require('telescope.themes').get_dropdown() },
|
||||||
@@ -521,7 +554,8 @@ do
|
|||||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader>sc', builtin.commands, { desc = '[S]earch [C]ommands' })
|
vim.keymap.set('n', '<leader>sc', builtin.commands, { desc = '[S]earch [C]ommands' })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><leader>', builtin.find_files, { desc = '[ ] Find files' })
|
||||||
|
vim.keymap.set('n', '<leader>sb', builtin.buffers, { desc = '[S]earch [B]uffers' })
|
||||||
|
|
||||||
-- Add Telescope-based LSP pickers when an LSP attaches to a buffer.
|
-- Add Telescope-based LSP pickers when an LSP attaches to a buffer.
|
||||||
-- If you later switch picker plugins, this is where to update these mappings.
|
-- If you later switch picker plugins, this is where to update these mappings.
|
||||||
@@ -560,10 +594,10 @@ do
|
|||||||
-- Override default behavior and theme when searching
|
-- Override default behavior and theme when searching
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
builtin.current_buffer_fuzzy_find {
|
||||||
winblend = 10,
|
winblend = 10,
|
||||||
previewer = false,
|
previewer = false,
|
||||||
})
|
}
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||||
|
|
||||||
-- It's also possible to pass additional configuration options.
|
-- It's also possible to pass additional configuration options.
|
||||||
@@ -715,7 +749,8 @@ do
|
|||||||
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
|
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
local current_settings = client.config.settings --[[@as lspconfig.settings.lua_ls]]
|
||||||
|
client.config.settings.Lua = vim.tbl_deep_extend('force', current_settings.Lua, {
|
||||||
runtime = {
|
runtime = {
|
||||||
version = 'LuaJIT',
|
version = 'LuaJIT',
|
||||||
path = { 'lua/?.lua', 'lua/?/init.lua' },
|
path = { 'lua/?.lua', 'lua/?/init.lua' },
|
||||||
@@ -724,10 +759,7 @@ do
|
|||||||
checkThirdParty = false,
|
checkThirdParty = false,
|
||||||
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
|
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
|
||||||
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
|
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
|
||||||
library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), {
|
library = vim.api.nvim_get_runtime_file('', true),
|
||||||
'${3rd}/luv/library',
|
|
||||||
'${3rd}/busted/library',
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
@@ -750,6 +782,11 @@ do
|
|||||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
||||||
require('mason').setup {}
|
require('mason').setup {}
|
||||||
|
|
||||||
|
-- Translates between nvim-lspconfig server names and mason.nvim package names (e.g. lua_ls <-> lua-language-server)
|
||||||
|
require('mason-lspconfig').setup {
|
||||||
|
automatic_enable = false, -- Change this to true if you want to automatically enable servers that are installed manually (e.g. via :Mason / :MasonInstall)
|
||||||
|
}
|
||||||
|
|
||||||
-- Ensure the servers and tools above are installed
|
-- Ensure the servers and tools above are installed
|
||||||
--
|
--
|
||||||
-- To check the current status of installed tools and/or manually install
|
-- To check the current status of installed tools and/or manually install
|
||||||
@@ -976,7 +1013,7 @@ do
|
|||||||
-- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
-- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||||
--
|
--
|
||||||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
||||||
-- require 'custom.plugins'
|
require 'custom.plugins'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
vim.pack.add {
|
||||||
|
{
|
||||||
|
src = 'https://github.com/nickjvandyke/opencode.nvim',
|
||||||
|
version = vim.version.range '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local opencode_port = 4096
|
||||||
|
local opencode_url = 'http://127.0.0.1:' .. opencode_port
|
||||||
|
|
||||||
|
---@type opencode.Opts
|
||||||
|
vim.g.opencode_opts = {
|
||||||
|
server = {
|
||||||
|
url = opencode_url,
|
||||||
|
start = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.o.autoread = true -- Required for `vim.g.opencode_opts.events.reload`.
|
||||||
|
|
||||||
|
vim.keymap.set({ 'n', 'x' }, '<leader>oa', function()
|
||||||
|
require('opencode').ask('@this: ')
|
||||||
|
end, { desc = 'Ask opencode' })
|
||||||
|
|
||||||
|
vim.keymap.set({ 'n', 'x' }, '<leader>os', function()
|
||||||
|
require('opencode').select()
|
||||||
|
end, { desc = 'Select opencode action' })
|
||||||
|
|
||||||
|
vim.keymap.set({ 'n', 'x' }, 'go', function()
|
||||||
|
return require('opencode').operator('@this ')
|
||||||
|
end, { desc = 'Add range to opencode', expr = true })
|
||||||
|
|
||||||
|
vim.keymap.set('n', 'goo', function()
|
||||||
|
return require('opencode').operator('@this ') .. '_'
|
||||||
|
end, { desc = 'Add line to opencode', expr = true })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<S-C-u>', function()
|
||||||
|
require('opencode').command('session.half.page.up')
|
||||||
|
end, { desc = 'Scroll opencode up' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<S-C-d>', function()
|
||||||
|
require('opencode').command('session.half.page.down')
|
||||||
|
end, { desc = 'Scroll opencode down' })
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
vim.pack.add {
|
||||||
|
{
|
||||||
|
src = 'https://github.com/alexpasmantier/tv.nvim',
|
||||||
|
version = 'main',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Built-in tv.nvim handlers.
|
||||||
|
local h = require('tv').handlers
|
||||||
|
|
||||||
|
require('tv').setup {
|
||||||
|
layout = 'landscape', -- 'landscape' (default) or 'portrait'
|
||||||
|
window = {
|
||||||
|
width = 0.8,
|
||||||
|
height = 0.8,
|
||||||
|
border = 'none',
|
||||||
|
title = ' tv.nvim ',
|
||||||
|
title_pos = 'center',
|
||||||
|
},
|
||||||
|
channels = {
|
||||||
|
files = {
|
||||||
|
layout = 'portrait',
|
||||||
|
keybinding = '<leader>tf',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = h.open_as_files,
|
||||||
|
['<C-q>'] = h.send_to_quickfix,
|
||||||
|
['<C-s>'] = h.open_in_split,
|
||||||
|
['<C-v>'] = h.open_in_vsplit,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
text = {
|
||||||
|
layout = 'portrait',
|
||||||
|
keybinding = '<C-p>',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = h.open_at_line,
|
||||||
|
['<C-q>'] = h.send_to_quickfix,
|
||||||
|
['<C-s>'] = h.open_in_split,
|
||||||
|
['<C-v>'] = h.open_in_vsplit,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
['git-log'] = {
|
||||||
|
keybinding = '<leader>gl',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = function(entries, config)
|
||||||
|
if #entries > 0 then
|
||||||
|
vim.cmd 'enew | setlocal buftype=nofile bufhidden=wipe'
|
||||||
|
vim.cmd('silent 0read !git show ' .. vim.fn.shellescape(entries[1]))
|
||||||
|
vim.cmd '1delete _ | setlocal filetype=git nomodifiable'
|
||||||
|
vim.cmd 'normal! gg'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
['git-branch'] = {
|
||||||
|
keybinding = '<leader>gb',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = h.execute_shell_command 'git checkout {}',
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
['docker-images'] = {
|
||||||
|
keybinding = '<leader>di',
|
||||||
|
window = { title = ' Docker Images ' },
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = function(entries, config)
|
||||||
|
if #entries > 0 then
|
||||||
|
vim.ui.input({
|
||||||
|
prompt = 'Container name: ',
|
||||||
|
default = 'my-container',
|
||||||
|
}, function(name)
|
||||||
|
if name and name ~= '' then
|
||||||
|
local cmd = string.format('docker run -it --name %s %s', name, entries[1])
|
||||||
|
vim.cmd('!' .. cmd)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
env = {
|
||||||
|
keybinding = '<leader>ev',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = h.insert_at_cursor,
|
||||||
|
['<C-l>'] = h.insert_on_new_line,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
alias = {
|
||||||
|
keybinding = '<leader>al',
|
||||||
|
handlers = {
|
||||||
|
['<CR>'] = h.insert_at_cursor,
|
||||||
|
['<C-y>'] = h.copy_to_clipboard,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tv_binary = 'tv',
|
||||||
|
global_keybindings = {
|
||||||
|
channels = '<leader>tv',
|
||||||
|
},
|
||||||
|
quickfix = {
|
||||||
|
auto_open = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
-- Zoxide integration for Neovim
|
||||||
|
-- Allows you to use zoxide's smart directory jumping within Neovim
|
||||||
|
|
||||||
|
-- Install telescope-zoxide plugin
|
||||||
|
local gh = function(repo)
|
||||||
|
return 'https://github.com/' .. repo
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.pack.add { gh 'jvgrootveld/telescope-zoxide' }
|
||||||
|
|
||||||
|
-- Configure telescope-zoxide
|
||||||
|
require('telescope').load_extension 'zoxide'
|
||||||
|
|
||||||
|
-- Keymaps for zoxide
|
||||||
|
vim.keymap.set('n', '<leader>cd', function()
|
||||||
|
require('telescope').extensions.zoxide.list()
|
||||||
|
end, { desc = '[C]hange [D]irectory with zoxide' })
|
||||||
|
|
||||||
|
-- Optional: Create a command to change directory using zoxide
|
||||||
|
vim.api.nvim_create_user_command('Z', function(opts)
|
||||||
|
local path = opts.args
|
||||||
|
if path == '' then
|
||||||
|
-- If no argument, open telescope picker
|
||||||
|
require('telescope').extensions.zoxide.list()
|
||||||
|
else
|
||||||
|
-- Otherwise, use zoxide to find and change to directory
|
||||||
|
local handle = io.popen('zoxide query -- ' .. vim.fn.shellescape(path))
|
||||||
|
if handle then
|
||||||
|
local result = handle:read '*a'
|
||||||
|
handle:close()
|
||||||
|
result = result:gsub('%s+$', '') -- trim trailing whitespace
|
||||||
|
if result ~= '' then
|
||||||
|
vim.cmd('cd ' .. vim.fn.fnameescape(result))
|
||||||
|
print('Changed directory to: ' .. result)
|
||||||
|
else
|
||||||
|
print('Directory not found in zoxide database')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, { nargs = '*', desc = 'Change directory using zoxide' })
|
||||||
|
|
||||||
|
-- Optional: Create commands similar to zoxide's zi (interactive)
|
||||||
|
vim.api.nvim_create_user_command('Zi', function()
|
||||||
|
require('telescope').extensions.zoxide.list()
|
||||||
|
end, { desc = 'Interactive zoxide directory picker' })
|
||||||
|
|
||||||
|
-- Optional: Add zoxide entries when changing directories in Neovim
|
||||||
|
-- This keeps your zoxide database in sync with Neovim directory changes
|
||||||
|
vim.api.nvim_create_autocmd('DirChanged', {
|
||||||
|
callback = function()
|
||||||
|
local dir = vim.fn.getcwd()
|
||||||
|
vim.fn.system('zoxide add ' .. vim.fn.shellescape(dir))
|
||||||
|
end,
|
||||||
|
desc = 'Add directory to zoxide database when changing directories in Neovim',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Custom directory aliases
|
||||||
|
-- Using command abbreviation since Neovim commands must start with uppercase
|
||||||
|
vim.cmd([[
|
||||||
|
cnoreabbrev <expr> cda getcmdtype() == ':' && getcmdline() == 'cda' ? 'cd $HOME/Syncthing/Git/ansible/' : 'cda'
|
||||||
|
]])
|
||||||
Reference in New Issue
Block a user