trying built-in telescope browser instead of vinegar

This commit is contained in:
Rudis Muiznieks 2023-04-25 10:54:01 -05:00
parent cd91da4ce2
commit 61eae2fd0f
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
5 changed files with 55 additions and 21 deletions

View File

@ -1,6 +1,3 @@
-- launch file browser when opening on a directory
vim.api.nvim_command('au VimEnter * lua require("userfuncs").browse_if_dir()')
-- recognize csx files as csharp -- recognize csx files as csharp
vim.api.nvim_command('au BufRead,BufNewFile *.csx set filetype=cs') vim.api.nvim_command('au BufRead,BufNewFile *.csx set filetype=cs')

View File

@ -12,7 +12,7 @@ vim.api.nvim_set_keymap('i', '<Up>', '<c-\\><c-o>gk', snoremap)
vim.api.nvim_set_keymap('i', '<Down>', '<c-\\><c-o>gj', snoremap) vim.api.nvim_set_keymap('i', '<Down>', '<c-\\><c-o>gj', snoremap)
-- file navigation -- file navigation
vim.api.nvim_set_keymap('n', '-', '<cmd>lua require("telescope").extensions.vinegar.file_browser()<cr>', noremap) vim.api.nvim_set_keymap('n', '-', '<cmd>:Telescope file_browser<cr>', noremap)
vim.api.nvim_set_keymap('n', '<F1>', '<cmd>b#<cr>', noremap) vim.api.nvim_set_keymap('n', '<F1>', '<cmd>b#<cr>', noremap)
vim.api.nvim_set_keymap('i', '<F1>', '<cmd>b#<cr>', noremap) vim.api.nvim_set_keymap('i', '<F1>', '<cmd>b#<cr>', noremap)
vim.api.nvim_set_keymap('n', '<leader>-', '<cmd>lua require("telescope.builtin").find_files('..cwdopt..')<cr>', noremap) vim.api.nvim_set_keymap('n', '<leader>-', '<cmd>lua require("telescope.builtin").find_files('..cwdopt..')<cr>', noremap)

View File

@ -37,16 +37,64 @@ require('luasnip.loaders.from_snipmate').lazy_load({
}) })
-- replace built in selector with telescope -- replace built in selector with telescope
local fb_actions = require'telescope'.extensions.file_browser.actions
require('telescope').setup { require('telescope').setup {
extensions = { extensions = {
["ui-select"] = { ["ui-select"] = {
require("telescope.themes").get_dropdown { require("telescope.themes").get_dropdown {}
-- even more opts },
} file_browser = {
} initial_mode = "normal",
hijack_netrw = true,
dir_icon = "",
mappings = {
["i"] = {
["<A-c>"] = false,
["<S-CR>"] = false,
["<A-r>"] = false,
["<A-m>"] = false,
["<A-y>"] = false,
["<A-d>"] = false,
["<C-o>"] = false,
["<C-g>"] = false,
["<C-e>"] = false,
["<C-w>"] = false,
["<C-t>"] = false,
["<C-f>"] = false,
["<C-h>"] = false,
["<C-s>"] = false,
["<Tab>"] = false,
["<S-Tab>"] = false,
["<bs>"] = false,
},
["n"] = {
c = false,
r = false,
m = false,
y = false,
d = false,
o = false,
g = false,
e = false,
w = false,
t = false,
f = false,
h = false,
s = false,
["<Tab>"] = false,
["<S-Tab>"] = false,
["-"] = fb_actions.goto_parent_dir,
["/"] = function()
vim.cmd('startinsert')
end,
["+"] = fb_actions.create,
},
},
},
} }
} }
require('telescope').load_extension('ui-select') require('telescope').load_extension('ui-select')
require('telescope').load_extension('file_browser')
-- autocomplete config -- autocomplete config
local cmp = require 'cmp' local cmp = require 'cmp'
@ -203,7 +251,7 @@ require'lualine'.setup {
lualine_x = {{ lualine_x = {{
"diagnostics", "diagnostics",
sources = {"nvim_lsp"}, sources = {"nvim_lsp"},
icons_enabled = false icons_enabled = true
}}, }},
lualine_y = {'progress'}, lualine_y = {'progress'},
lualine_z = {'location'}, lualine_z = {'location'},

View File

@ -2,6 +2,7 @@ return require('packer').startup(function()
local pid = vim.fn.getpid() local pid = vim.fn.getpid()
use 'wbthomason/packer.nvim' -- plugin manager use 'wbthomason/packer.nvim' -- plugin manager
use 'nvim-tree/nvim-web-devicons' -- file icons
use 'rktjmp/lush.nvim' use 'rktjmp/lush.nvim'
use { -- color scheme use { -- color scheme
'catppuccin/nvim', 'catppuccin/nvim',
@ -35,7 +36,6 @@ return require('packer').startup(function()
use 'Pocco81/TrueZen.nvim' -- distraction free writing use 'Pocco81/TrueZen.nvim' -- distraction free writing
use 'https://code.sitosis.com/rudism/telescope-dict.nvim.git' -- thesaurus and dictionary use 'https://code.sitosis.com/rudism/telescope-dict.nvim.git' -- thesaurus and dictionary
use 'nvim-telescope/telescope-file-browser.nvim' -- file picker use 'nvim-telescope/telescope-file-browser.nvim' -- file picker
use 'https://code.sitosis.com/rudism/telescope-vinegar.nvim.git' -- thesaurus and dictionary
use 'tpope/vim-dadbod' -- database query runner use 'tpope/vim-dadbod' -- database query runner
use 'tpope/vim-dotenv' -- .env configuration support use 'tpope/vim-dotenv' -- .env configuration support
use 'kristijanhusak/vim-dadbod-completion' -- sql completion use 'kristijanhusak/vim-dadbod-completion' -- sql completion

View File

@ -25,17 +25,6 @@ local rootfiles = {
'*.sln' '*.sln'
} }
M.browse_if_dir = function()
if require('plenary.path'):new(vim.fn.expand('%:p')):is_dir() then
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_option(buf, 'buftype', 'nofile')
vim.api.nvim_buf_set_option(buf, 'buflisted', false)
vim.api.nvim_buf_set_option(buf, 'swapfile', false)
vim.api.nvim_buf_set_option(buf, 'bufhidden', 'hide')
require('telescope').extensions.vinegar.file_browser()
end
end
M.find_project_root = function() M.find_project_root = function()
local stop_at = parent_dir(os.getenv('HOME')) local stop_at = parent_dir(os.getenv('HOME'))
local cwd = vim.fn.expand('%:p:h') local cwd = vim.fn.expand('%:p:h')