feat: add telescope
This commit is contained in:
parent
394c2db554
commit
6920fe2ca3
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Neovim Config
|
||||||
|
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
* ripgrep - for telescope
|
||||||
|
* [A patched font](https://www.nerdfonts.com/) - for dev icons
|
||||||
|
|
||||||
|
|
1
lua/config/devicons.lua
Normal file
1
lua/config/devicons.lua
Normal file
@ -0,0 +1 @@
|
|||||||
|
require('nvim-web-devicons').setup()
|
74
lua/config/telescope.lua
Normal file
74
lua/config/telescope.lua
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
local telescope = require('telescope')
|
||||||
|
local map = require('utils.map')
|
||||||
|
local actions = require('telescope.actions')
|
||||||
|
local builtin = require('telescope.builtin')
|
||||||
|
local previewers = require('telescope.previewers')
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function sizelimit_maker(filepath, bufnr, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local size_limit = 100 * 1024 -- 100KiB
|
||||||
|
|
||||||
|
filepath = vim.fn.expand(filepath)
|
||||||
|
vim.loop.fs_stat(filepath, function(_, stat)
|
||||||
|
if not stat then return end
|
||||||
|
if stat.size > size_limit then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Falling back to find_files if git_files can't find a .git directory
|
||||||
|
function M.project_files(opts)
|
||||||
|
local ok = pcall(builtin.git_files, opts)
|
||||||
|
if not ok then builtin.find_files(opts) end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.edit_config(opts)
|
||||||
|
return M.project_files{
|
||||||
|
cwd = "~/.config/nvim",
|
||||||
|
prompt_title = "Neovim config"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local silent = {silent = true}
|
||||||
|
|
||||||
|
-- Search project files
|
||||||
|
map('n', '<C-p>', [[:lua require('config.telescope').project_files()<cr>]], silent)
|
||||||
|
|
||||||
|
-- Edit neovim config
|
||||||
|
map('n', '<leader>ev', [[:lua require('config.telescope').edit_config()<cr>]], silent)
|
||||||
|
|
||||||
|
-- Grep string
|
||||||
|
map('n', '<leader>fg', [[:lua require('telescope.builtin').live_grep()<cr>]], silent)
|
||||||
|
|
||||||
|
telescope.setup{
|
||||||
|
defaults = {
|
||||||
|
buffer_previewer_maker = new_maker,
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<esc>"] = actions.close
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pickers = {
|
||||||
|
find_files = {
|
||||||
|
theme = "dropdown",
|
||||||
|
},
|
||||||
|
git_files = {
|
||||||
|
theme = "dropdown",
|
||||||
|
},
|
||||||
|
live_grep = {
|
||||||
|
theme = "dropdown",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local fzfPlugin = packer_plugins["telescope-fzf-native.nvim"]
|
||||||
|
if fzfPlugin and fzfPlugin.loaded then
|
||||||
|
telescope.load_extension('fzf')
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
6
lua/config/treesitter.lua
Normal file
6
lua/config/treesitter.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
local treesitter = require("nvim-treesitter.configs")
|
||||||
|
|
||||||
|
treesitter.setup{
|
||||||
|
ensure_installed = "maintained",
|
||||||
|
highlight = { enable = true }
|
||||||
|
}
|
@ -9,6 +9,10 @@ cmd [[filetype plugin on]]
|
|||||||
local buffer = { o, bo }
|
local buffer = { o, bo }
|
||||||
local window = { o, wo }
|
local window = { o, wo }
|
||||||
|
|
||||||
|
-- Pseudo transparent popup window
|
||||||
|
opt('pumblend', 15)
|
||||||
|
cmd [[highlight PmenuSel blend=0]]
|
||||||
|
|
||||||
-- Don't wrap text to next line if there isin't enough space
|
-- Don't wrap text to next line if there isin't enough space
|
||||||
opt('wrap', false)
|
opt('wrap', false)
|
||||||
|
|
||||||
@ -82,7 +86,7 @@ opt('clipboard', 'unnamedplus')
|
|||||||
|
|
||||||
-- Identation/Tab settings
|
-- Identation/Tab settings
|
||||||
local tab_size = 2
|
local tab_size = 2
|
||||||
opt('foldmethod', 'indent', window)
|
opt('foldmethod', 'indent')
|
||||||
opt('expandtab', false, buffer)
|
opt('expandtab', false, buffer)
|
||||||
opt('smartindent', true, buffer)
|
opt('smartindent', true, buffer)
|
||||||
opt('shiftwidth', tab_size, buffer)
|
opt('shiftwidth', tab_size, buffer)
|
||||||
|
@ -9,6 +9,29 @@ local function usePlugins(use)
|
|||||||
-- Various lua utilities
|
-- Various lua utilities
|
||||||
use 'nvim-lua/plenary.nvim'
|
use 'nvim-lua/plenary.nvim'
|
||||||
|
|
||||||
|
-- Tree-sitter
|
||||||
|
use {
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
config = [[require 'config.treesitter']],
|
||||||
|
run = ':TSUpdate'
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Emoji file icons
|
||||||
|
use { 'kyazdani42/nvim-web-devicons', config = [[require 'config.devicons']] }
|
||||||
|
|
||||||
|
-- Fuzzy file finder
|
||||||
|
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
|
||||||
|
use {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
config = [[require 'config.telescope']],
|
||||||
|
requires = {
|
||||||
|
{'nvim-lua/plenary.nvim'},
|
||||||
|
{'nvim-treesitter/nvim-treesitter'},
|
||||||
|
{'kyazdani42/nvim-web-devicons', opt = true},
|
||||||
|
{'nvim-telescope/telescope-fzf-native.nvim', opt = true}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Smooth smooth scrolling
|
-- Smooth smooth scrolling
|
||||||
use 'psliwka/vim-smoothie'
|
use 'psliwka/vim-smoothie'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user