New telescope config, keymaps, and options

This commit is contained in:
Eduardo Cueto-Mendoza 2023-08-29 18:43:49 +01:00
parent 413b072d53
commit 008841b34d
3 changed files with 365 additions and 161 deletions

View File

@ -1,15 +1,81 @@
require('telescope').setup{ local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
local actions = require "telescope.actions"
telescope.setup {
defaults = { defaults = {
-- Default configuration for telescope goes here:
-- config_key = value, prompt_prefix = "",
selection_caret = "",
path_display = { "smart" },
mappings = { mappings = {
i = { i = {
-- map actions.which_key to <C-h> (default: <C-/>) ["<C-n>"] = actions.cycle_history_next,
-- actions.which_key shows the mappings for your picker, ["<C-p>"] = actions.cycle_history_prev,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key" ["<C-j>"] = actions.move_selection_next,
} ["<C-k>"] = actions.move_selection_previous,
}
["<C-c>"] = actions.close,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["<C-l>"] = actions.complete_tag,
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
},
n = {
["<esc>"] = actions.close,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["j"] = actions.move_selection_next,
["k"] = actions.move_selection_previous,
["H"] = actions.move_to_top,
["M"] = actions.move_to_middle,
["L"] = actions.move_to_bottom,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["gg"] = actions.move_to_top,
["G"] = actions.move_to_bottom,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["?"] = actions.which_key,
},
},
}, },
pickers = { pickers = {
-- Default configuration for builtin pickers goes here: -- Default configuration for builtin pickers goes here:
@ -19,6 +85,9 @@ require('telescope').setup{
-- } -- }
-- Now the picker_config_key will be applied every time you call this -- Now the picker_config_key will be applied every time you call this
-- builtin picker -- builtin picker
planets = {
show_pluto = true,
},
}, },
extensions = { extensions = {
-- Your extension configuration goes here: -- Your extension configuration goes here:
@ -26,5 +95,6 @@ require('telescope').setup{
-- extension_config_key = value, -- extension_config_key = value,
-- } -- }
-- please take a look at the readme of the extension you want to configure -- please take a look at the readme of the extension you want to configure
} },
} }

View File

@ -1,74 +1,161 @@
----------------- local opts = { noremap = true, silent = true }
-- Normal mode --
-----------------
-- Hint: see `:h vim.map.set()` local term_opts = { silent = true }
-- Shorten function name
local keymap = vim.api.nvim_set_keymap
--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Modes
-- normal_mode = "n",
-- insert_mode = "i",
-- visual_mode = "v",
-- visual_block_mode = "x",
-- term_mode = "t",
-- command_mode = "c",
-- Normal --
-- Better window navigation -- Better window navigation
vim.keymap.set("n", "<C-h>", "<C-w>h", opts) keymap("n", "<C-h>", "<C-w>h", opts)
vim.keymap.set("n", "<C-j>", "<C-w>j", opts) keymap("n", "<C-j>", "<C-w>j", opts)
vim.keymap.set("n", "<C-k>", "<C-w>k", opts) keymap("n", "<C-k>", "<C-w>k", opts)
vim.keymap.set("n", "<C-l>", "<C-w>l", opts) keymap("n", "<C-l>", "<C-w>l", opts)
keymap("n", "<leader>e", ":Lex 30<cr>", opts)
-- Resize with arrows -- Resize with arrows
-- delta: 2 lines keymap("n", "<C-Up>", ":resize -2<CR>", opts)
vim.keymap.set("n", "<C-Up>", ":resize -2<CR>", opts) keymap("n", "<C-Down>", ":resize +2<CR>", opts)
vim.keymap.set("n", "<C-Down>", ":resize +2<CR>", opts) keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", opts) keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", opts)
-- open File Explorer
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- Navigate buffers -- Navigate buffers
vim.keymap.set("n", "<BS>", ":bnext<CR>", opts) keymap("n", "<S-l>", ":bnext<CR>", opts)
vim.keymap.set("n", "<S-TAB>", ":bprevious<CR>", opts) keymap("n", "<S-h>", ":bprevious<CR>", opts)
-- Telescope -- Move text up and down
--local builtin = require("telescope.builtin") keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
--vim.keymap.set("n", "<leader>pf", builtin.find_files, {}) keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
--vim.keymap.set("n", "<C-p>", builtin.git_files, {})
--vim.keymap.set("n", "<leader>ps", function ()
-- builtin.grep_string( { search = vim.fn.input("Grep > ") } );
--end)
-- Harpoon -- Insert --
--local mark = require("harpoon.mark") -- Press jk fast to enter
--local ui = require("harpoon.ui") keymap("i", "jk", "<ESC>", opts)
--vim.keymap.set("n", "<leader>a", mark.add_file) keymap("i", "kj", "<ESC>", opts)
--vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
-- Visual --
-- Stay in indent mode
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- Move text up and down
keymap("v", "<A-j>", ":m .+1<CR>==", opts)
keymap("v", "<A-k>", ":m .-2<CR>==", opts)
keymap("v", "p", '"_dP', opts)
-- Visual Block --
-- Move text up and down
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
-- Terminal --
-- Better terminal navigation
keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)
-- keymap("n", "<leader>f", "<cmd>Telescope find_files<cr>", opts)
keymap("n", "<leader>f", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", opts)
keymap("n", "<C-g>", "<cmd>Telescope live_grep<cr>", opts)
keymap("n", "<leader>pv", "<cmd>Ex<cr>", opts)
-------------------
---- Normal mode --
-------------------
--local opts = { noremap = true, silent = true }
-- --
--vim.keymap.set("n", "<C-h>", function () ui.nav_file(1) end) --local term_opts = { silent = true }
--vim.keymap.set("n", "<C-t>", function () ui.nav_file(2) end) --
--vim.keymap.set("n", "<C-n>", function () ui.nav_file(3) end) ---- Shorten function name
--vim.keymap.set("n", "<C-s>", function () ui.nav_file(4) end) --local keymap = vim.api.nvim_set_keymap
--
-- Undotree ----Remap space as leader key
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle) --keymap("", "<Space>", "<Nop>", opts)
--
-- Fugitive ---- Hint: see `:h vim.map.set()`
vim.keymap.set("n", "<leader>gs", vim.cmd.Git) ---- Better window navigation
--vim.keymap.set("n", "<C-h>", "<C-w>h", opts)
-- Put line bellow in-front of line --vim.keymap.set("n", "<C-j>", "<C-w>j", opts)
vim.keymap.set("n", "J", "mzJ`z") --vim.keymap.set("n", "<C-k>", "<C-w>k", opts)
--vim.keymap.set("n", "<C-l>", "<C-w>l", opts)
-- Keep cursor in the middle --
vim.keymap.set("n", "<C-d>", "<C-d>zz") ---- Resize with arrows
vim.keymap.set("n", "<C-u>", "<C-u>zz") ---- delta: 2 lines
vim.keymap.set("n", "n", "nzzzv") --vim.keymap.set("n", "<C-Up>", ":resize -2<CR>", opts)
vim.keymap.set("n", "N", "Nzzzv") --vim.keymap.set("n", "<C-Down>", ":resize +2<CR>", opts)
--vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", opts)
-- Don't loose buffer --vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", opts)
vim.keymap.set("x", "<leader>p", "\"_dP") --
---- open File Explorer
--vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
----------------- --
-- Visual mode -- ---- Navigate buffers
----------------- --vim.keymap.set("n", "<BS>", ":bnext<CR>", opts)
--vim.keymap.set("n", "<S-TAB>", ":bprevious<CR>", opts)
-- Hint: start visual mode with the same area as the previous area and the same mode --
vim.keymap.set("v", "<", "<gv", opts) ---- Telescope
vim.keymap.set("v", ">", ">gv", opts) ----local builtin = require("telescope.builtin")
----vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
-- Move text on visual mode ----vim.keymap.set("n", "<C-p>", builtin.git_files, {})
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opts) ----vim.keymap.set("n", "<leader>ps", function ()
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opts) ---- builtin.grep_string( { search = vim.fn.input("Grep > ") } );
----end)
--
---- Harpoon
----local mark = require("harpoon.mark")
----local ui = require("harpoon.ui")
----vim.keymap.set("n", "<leader>a", mark.add_file)
----vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
----
----vim.keymap.set("n", "<C-h>", function () ui.nav_file(1) end)
----vim.keymap.set("n", "<C-t>", function () ui.nav_file(2) end)
----vim.keymap.set("n", "<C-n>", function () ui.nav_file(3) end)
----vim.keymap.set("n", "<C-s>", function () ui.nav_file(4) end)
--
---- Undotree
--vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
--
---- Fugitive
--vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
--
---- Put line bellow in-front of line
--vim.keymap.set("n", "J", "mzJ`z")
--
---- Keep cursor in the middle
--vim.keymap.set("n", "<C-d>", "<C-d>zz")
--vim.keymap.set("n", "<C-u>", "<C-u>zz")
--vim.keymap.set("n", "n", "nzzzv")
--vim.keymap.set("n", "N", "Nzzzv")
--
---- Don't loose buffer
--vim.keymap.set("x", "<leader>p", "\"_dP")
--
--
-------------------
---- Visual mode --
-------------------
--
---- Hint: start visual mode with the same area as the previous area and the same mode
--vim.keymap.set("v", "<", "<gv", opts)
--vim.keymap.set("v", ">", ">gv", opts)
--
---- Move text on visual mode
--vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opts)
--vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opts)

View File

@ -1,90 +1,137 @@
-- Hint: use `:h <option>` to figure out the meaning if needed local options = {
vim.opt.clipboard = "unnamedplus" -- use system clipboard backup = false, -- creates a backup file
vim.opt.completeopt = {"menu", "menuone", "noselect"} clipboard = "unnamedplus", -- allows neovim to access the system clipboard
vim.opt.mouse = "a" -- allow the mouse to be used in Nvim cmdheight = 2, -- more space in the neovim command line for displaying messages
completeopt = { "menuone", "noselect" }, -- mostly just for cmp
conceallevel = 0, -- so that `` is visible in markdown files
fileencoding = "utf-8", -- the encoding written to a file
hlsearch = true, -- highlight all matches on previous search pattern
ignorecase = true, -- ignore case in search patterns
mouse = "a", -- allow the mouse to be used in neovim
pumheight = 10, -- pop up menu height
showmode = false, -- we don't need to see things like -- INSERT -- anymore
showtabline = 2, -- always show tabs
smartcase = true, -- smart case
smartindent = true, -- make indenting smarter again
splitbelow = true, -- force all horizontal splits to go below current window
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
-- termguicolors = true, -- set term gui colors (most terminals support this)
timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds)
undofile = true, -- enable persistent undo
updatetime = 300, -- faster completion (4000ms default)
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- convert tabs to spaces
shiftwidth = 4, -- the number of spaces inserted for each indentation
tabstop = 4, -- insert 4 spaces for a tab
cursorline = true, -- highlight the current line
number = true, -- set numbered lines
relativenumber = true, -- set relative numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
wrap = true, -- display lines as one long line
scrolloff = 8, -- is one of my fav
sidescrolloff = 8,
guifont = "monospace:h17", -- the font used in graphical neovim applications
}
-- Fonts vim.opt.shortmess:append "c"
vim.opt.encoding="utf-8"
vim.opt.guifont = "Meslo LG M Bold for Powerline:h10"
-- Tab for k, v in pairs(options) do
vim.opt.tabstop = 4 -- number of visual spaces per TAB vim.opt[k] = v
vim.opt.softtabstop = 4 -- number of spacesin tab when editing end
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
-- UI config vim.cmd "set whichwrap+=<,>,[,],h,l"
vim.opt.number = true -- show absolute number vim.cmd [[set iskeyword+=-]]
vim.opt.relativenumber = true -- add numbers to each line on the left side vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work
vim.opt.cursorline = false -- highlight cursor line underneath the cursor horizontally
vim.opt.splitbelow = true -- open new vertical split bottom
vim.opt.splitright = true -- open new horizontal splits right
vim.opt.termguicolors = true -- enable 23-bit RGB color in the TUI
vim.opt.showmode = false -- we are experienced, wo don"t need the "-- INSERT --" mode hint
-- File recovery options ---- Hint: use `:h <option>` to figure out the meaning if needed
vim.opt.swapfile = false --vim.opt.clipboard = "unnamedplus" -- use system clipboard
vim.opt.backup = false --vim.opt.completeopt = {"menu", "menuone", "noselect"}
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" --vim.opt.mouse = "a" -- allow the mouse to be used in Nvim
vim.opt.undofile = true --
---- Fonts
-- Color column --vim.opt.encoding="utf-8"
vim.opt.colorcolumn = "80" --vim.opt.guifont = "Meslo LG M Bold for Powerline:h10"
--
-- Searching ---- Tab
vim.opt.incsearch = true -- search as characters are entered --vim.opt.tabstop = 4 -- number of visual spaces per TAB
vim.opt.hlsearch = false -- do not highlight matches --vim.opt.softtabstop = 4 -- number of spacesin tab when editing
vim.opt.ignorecase = true -- ignore case in searches by default --vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered --vim.opt.expandtab = true -- tabs are spaces, mainly because of python
--
-- LSP options ---- UI config
vim.diagnostic.config({ --vim.opt.number = true -- show absolute number
virtual_text = false --vim.opt.relativenumber = true -- add numbers to each line on the left side
}) --vim.opt.cursorline = false -- highlight cursor line underneath the cursor horizontally
-- Show line diagnostics automatically in hover window --vim.opt.splitbelow = true -- open new vertical split bottom
vim.o.updatetime = 250 --vim.opt.splitright = true -- open new horizontal splits right
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] --vim.opt.termguicolors = true -- enable 23-bit RGB color in the TUI
--vim.opt.showmode = false -- we are experienced, wo don"t need the "-- INSERT --" mode hint
--
---- File recovery options
-- Leader key --vim.opt.swapfile = false
vim.g.mapleader = " " --vim.opt.backup = false
--vim.g.maplocalleader = " " --vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.g.maplocalleader = "\\" --vim.opt.undofile = true
--
-- Airline ---- Color column
vim.g.airline_powerline_fonts = 1 --vim.opt.colorcolumn = "80"
--
-- Zig ---- Searching
vim.g.zig_fmt_autosave = 1 --vim.opt.incsearch = true -- search as characters are entered
-- Set completeopt to have a better completion experience --vim.opt.hlsearch = false -- do not highlight matches
--set completeopt=menuone,noinsert,noselect --vim.opt.ignorecase = true -- ignore case in searches by default
vim.opt.completeopt = "menuone,noinsert,noselect" --vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
-- Enable completions as you type --
vim.g.completion_enable_auto_popup = 1 ---- LSP options
--vim.diagnostic.config({
-- Python -- virtual_text = false
vim.g.loaded_python_provider = 0 --})
vim.g.python3_host_prog = "/usr/local/bin/python" ---- Show line diagnostics automatically in hover window
--vim.o.updatetime = 250
-- Vimtex options: --vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
vim.g.vimtex_view_method = "zathura" --
vim.g.vimtex_general_viewer = "zathura" --
vim.g.vimtex_quickfix_mode = 0 --
---- Leader key
-- Ignore mappings --vim.g.mapleader = " "
vim.g.vimtex_mappings_enabled = 1 ----vim.g.maplocalleader = " "
--vim.g.maplocalleader = "\\"
---- Auto Indent --
--vim.g["vimtex_indent_enabled"] = 1 ---- Airline
--vim.g.airline_powerline_fonts = 1
---- Syntax highlighting --
vim.g.vimtex_syntax_enabled = 0 ---- Zig
--vim.g.zig_fmt_autosave = 1
-- Error suppression: ---- Set completeopt to have a better completion experience
vim.g.vimtex_log_ignore = ({ ----set completeopt=menuone,noinsert,noselect
"Underfull", --vim.opt.completeopt = "menuone,noinsert,noselect"
"Overfull", ---- Enable completions as you type
"specifier changed to", --vim.g.completion_enable_auto_popup = 1
"Token not allowed in a PDF string", --
}) ---- Python
--vim.g.loaded_python_provider = 0
--vim.g.python3_host_prog = "/usr/local/bin/python"
--
---- Vimtex options:
--vim.g.vimtex_view_method = "zathura"
--vim.g.vimtex_general_viewer = "zathura"
--vim.g.vimtex_quickfix_mode = 0
--
---- Ignore mappings
--vim.g.vimtex_mappings_enabled = 1
--
------ Auto Indent
----vim.g["vimtex_indent_enabled"] = 1
--
------ Syntax highlighting
--vim.g.vimtex_syntax_enabled = 0
--
---- Error suppression:
--vim.g.vimtex_log_ignore = ({
-- "Underfull",
-- "Overfull",
-- "specifier changed to",
-- "Token not allowed in a PDF string",
--})