I'm following a Neovim tutorial on LaraCasts from Jess Archer, setting up Neovim.
I've used Vim for a while, but I'm new with Neovim.
You can see Jess Archers dotfiles here: Jess Archers Dotfiles.
I would like to set it up, so whenever I open a new file using Telescope, that it automatically saves and closes the file (buffer) I have open, to avoid a bunch of open buffers like this:
Here is my current telescope-settings file:
local telescope = require('telescope')
local actions = require('telescope.actions')
vim.cmd([[
highlight link TelescopePromptTitle PMenuSel
highlight link TelescopePreviewTitle PMenuSel
highlight link TelescopePromptNormal NormalFloat
highlight link TelescopePromptBorder FloatBorder
highlight link TelescopeNormal CursorLine
highlight link TelescopeBorder CursorLineBg
]])
telescope.setup({
defaults = {
path_display = { truncate = 1 },
prompt_prefix = ' ',
selection_caret = ' ',
layout_config = {
prompt_position = 'top',
},
sorting_strategy = 'ascending',
mappings = {
i = {
['<esc>'] = actions.close,
['<C-Down>'] = actions.cycle_history_next,
['<C-Up>'] = actions.cycle_history_prev,
},
},
file_ignore_patterns = { '.git/', 'dist/', 'node%_modules/' },
},
pickers = {
find_files = {
hidden = true,
},
buffers = {
previewer = false,
layout_config = {
width = 80,
},
},
oldfiles = {
prompt_title = 'History',
},
lsp_references = {
previewer = false,
},
},
})
require('telescope').load_extension('fzf')
require('telescope').load_extension('live_grep_args')
vim.keymap.set('n', '<leader>f', [[<cmd>lua require('telescope.builtin').find_files()<CR>]])
vim.keymap.set('n', '<leader>F', [[<cmd>lua require('telescope.builtin').find_files({ no_ignore = true, prompt_title = 'All Files' })<CR>]]) -- luacheck: no max line length
vim.keymap.set('n', '<leader>b', [[<cmd>lua require('telescope.builtin').buffers()<CR>]])
vim.keymap.set('n', '<leader>g', [[<cmd>lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>]])
vim.keymap.set('n', '<leader>h', [[<cmd>lua require('telescope.builtin').oldfiles()<CR>]])
vim.keymap.set('n', '<leader>s', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]])
Solution attempt 1: Read Telescope's Github page and Telescope's help-pages
I read here: Telescope on Github.
And I also read this: :help telescope
. But there is a lot! I can't find what I'm looking for. I was searching for these possibilities:
- 'Save and close buffer when opening new file'
- 'Disable buffers'
- 'Open new file i current buffer' (I know that this is now actually what happens, but that's what if kind of feels like for the user).
Solution attempt 2: Setup (another) auto-save plugin
I looked at auto-save.nvim. It just seems a bit extensive to add an entire plugin for something that might be handled directly by Telescope.
:LeaderfBuffer
to navigate buffers. Probably telscope has this feature as well. (leaderf plugin)