Initial Commit

This commit is contained in:
kossLAN 2024-08-26 22:37:32 -04:00
commit fd4cc7c8e6
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
31 changed files with 2687 additions and 0 deletions

139
nvim/plugin/telescope.lua Normal file
View file

@ -0,0 +1,139 @@
if vim.g.did_load_telescope_plugin then
return
end
vim.g.did_load_telescope_plugin = true
local telescope = require('telescope')
local actions = require('telescope.actions')
local builtin = require('telescope.builtin')
local layout_config = {
vertical = {
width = function(_, max_columns)
return math.floor(max_columns * 0.99)
end,
height = function(_, _, max_lines)
return math.floor(max_lines * 0.99)
end,
prompt_position = 'bottom',
preview_cutoff = 0,
},
}
-- Fall back to find_files if not in a git repo
local project_files = function()
local opts = {} -- define here if you want to define something
local ok = pcall(builtin.git_files, opts)
if not ok then
builtin.find_files(opts)
end
end
---@param picker function the telescope picker to use
local function grep_current_file_type(picker)
local current_file_ext = vim.fn.expand('%:e')
local additional_vimgrep_arguments = {}
if current_file_ext ~= '' then
additional_vimgrep_arguments = {
'--type',
current_file_ext,
}
end
local conf = require('telescope.config').values
picker {
vimgrep_arguments = vim.tbl_flatten {
conf.vimgrep_arguments,
additional_vimgrep_arguments,
},
}
end
--- Grep the string under the cursor, filtering for the current file type
local function grep_string_current_file_type()
grep_current_file_type(builtin.grep_string)
end
--- Live grep, filtering for the current file type
local function live_grep_current_file_type()
grep_current_file_type(builtin.live_grep)
end
--- Like live_grep, but fuzzy (and slower)
local function fuzzy_grep(opts)
opts = vim.tbl_extend('error', opts or {}, { search = '', prompt_title = 'Fuzzy grep' })
builtin.grep_string(opts)
end
local function fuzzy_grep_current_file_type()
grep_current_file_type(fuzzy_grep)
end
vim.keymap.set('n', '<leader>tp', function()
builtin.find_files()
end, { desc = '[t]elescope find files - ctrl[p] style' })
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
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><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
telescope.setup {
defaults = {
path_display = {
'truncate',
},
layout_strategy = 'vertical',
layout_config = layout_config,
mappings = {
i = {
['<C-q>'] = actions.send_to_qflist,
['<C-l>'] = actions.send_to_loclist,
-- ['<esc>'] = actions.close,
['<C-s>'] = actions.cycle_previewers_next,
['<C-a>'] = actions.cycle_previewers_prev,
},
n = {
q = actions.close,
},
},
preview = {
treesitter = true,
},
history = {
path = vim.fn.stdpath('data') .. '/telescope_history.sqlite3',
limit = 1000,
},
color_devicons = true,
set_env = { ['COLORTERM'] = 'truecolor' },
prompt_prefix = '',
selection_caret = ' ',
entry_prefix = ' ',
initial_mode = 'insert',
vimgrep_arguments = {
'rg',
'-L',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case',
},
},
extensions = {
fzy_native = {
override_generic_sorter = false,
override_file_sorter = true,
},
},
}
telescope.load_extension('fzy_native')
-- telescope.load_extension('smart_history')