Compare commits

...

4 Commits

3 changed files with 85 additions and 0 deletions

View File

@ -32,11 +32,28 @@ key('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', { desc = '[F]ind [g]rep'
key('n', '<leader>fw', '<cmd>Telescope grep_string<cr>', { desc = '[F]ind [w]ord' })
key('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', { desc = '[F]ind [h]elp (tags)' })
key('n', '<leader>fd', '<cmd>Telescope diagnostics<cr>', { desc = '[F]ind [d]iagnostics' })
key('n', '<leader>fk', '<cmd>Telescope keymaps<cr>', { desc = '[F]ind [k]eymaps' })
key('n', '<leader>fF', function()
require('telescope.builtin').find_files { hidden = true }
end, { desc = '[F]ind [F]iles (with hidden)' })
key('n', '<leader>td', function()
require('lupan.ui').tab_change_dir()
end, { desc = '[T]ab change [d]irectory' })
key('n', '<leader>tD', function()
require('lupan.ui').tab_change_dir_newtab()
end, { desc = '[T]ab change [D]irectory (new tab)' })
key('n', '<leader>tm', function()
require('telescope-tabs').list_tabs(require 'telescope.themes'.get_dropdown())
end, { desc = '[T]ab change [D]irectory (new tab)' })
key('n', '<leader>tt', function()
require('telescope-tabs').go_to_previous()
end, { desc = '[T]ab [t]oggle previous' })
-- Diagnostic keymaps
key('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
key('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
@ -126,3 +143,13 @@ for i = 1, 9, 1 do
require("harpoon.term").gotoTerminal(i)
end, { desc = '[H]arpoon nav_file [' .. i .. ']' })
end
-- colors
key('n', '<F6>', function()
if vim.o.background == "dark" then
vim.o.background = "light"
else
vim.o.background = "dark"
end
end)

View File

@ -0,0 +1,44 @@
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local finders = require "telescope.finders"
local pickers = require "telescope.pickers"
local sorters = require "telescope.sorters"
local themes = require "telescope.themes"
local M = {}
local function enter(prompt_bufnr, action)
local selected = action_state.get_selected_entry()
actions.close(prompt_bufnr)
action(selected[1])
end
function M.tab_change_dir(opts)
opts = opts or {}
local action = opts.action or vim.cmd.tc
local prompt_title = opts.prompt_title or "Tab change directory"
local cmd = { 'find', os.getenv('HOME'), '-maxdepth', '5', '-type', 'd', '-not', '-path', '*/.git*' }
local dropdown = themes.get_dropdown();
local picker_opts = {
prompt_title = prompt_title,
finder = finders.new_oneshot_job(cmd, {}),
sorter = sorters.get_fuzzy_file({}),
attach_mappings = function(_, map)
map({ "i", "n" }, "<CR>", function(prompt_bufnr) enter(prompt_bufnr, action) end)
return true
end
}
local change_dir = pickers.new(dropdown, picker_opts)
change_dir:find()
end
local function tabnew_tcd(dir)
vim.cmd.tabnew(dir)
vim.cmd.tc(dir)
end
function M.tab_change_dir_newtab()
M.tab_change_dir({ action = tabnew_tcd, prompt_title = "Tab change directory (new tab)" })
end
return M

View File

@ -0,0 +1,14 @@
return {
'LukasPietzschmann/telescope-tabs',
dependencies = { 'nvim-telescope/telescope.nvim' },
lazy = true,
config = function()
require 'telescope-tabs'.setup {
entry_formatter = function(tab_id, buffer_ids, file_names, file_paths, is_current)
local cwd = vim.fn.getcwd(-1, tab_id)
local entry_string = table.concat(file_names, ', ')
return string.format('%d: %s %s%s', tab_id, cwd, entry_string, is_current and ' <' or '')
end,
}
end
}