From e7e692661e98d2e4b495d29c641d626a35f16e16 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Sun, 17 Jul 2022 02:28:01 +0930 Subject: [PATCH] Sun 17 Jul 2022 02:28:01 ACST --- .config/nvim/init.lua | 11 ++ .config/nvim/init.vim | 241 ------------------------ .config/nvim/lua/autocmd.lua | 33 ++++ .config/nvim/lua/options.lua | 30 +++ .config/nvim/lua/packer-plugins.lua | 25 +++ .config/nvim/lua/remaps.lua | 35 ++++ .config/nvim/plugin/coc.lua | 21 +++ .config/nvim/plugin/gruvbox.lua | 1 + .config/nvim/plugin/packer_compiled.lua | 159 ++++++++++++++++ .config/nvim/plugin/php-doc.lua | 7 + .config/nvim/plugin/telescope.lua | 60 ++++++ .config/nvim/plugin/tmux.lua | 17 ++ .config/nvim/telescope.lua | 27 --- update.sh | 6 +- 14 files changed, 403 insertions(+), 270 deletions(-) create mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/init.vim create mode 100644 .config/nvim/lua/autocmd.lua create mode 100644 .config/nvim/lua/options.lua create mode 100644 .config/nvim/lua/packer-plugins.lua create mode 100644 .config/nvim/lua/remaps.lua create mode 100644 .config/nvim/plugin/coc.lua create mode 100644 .config/nvim/plugin/gruvbox.lua create mode 100644 .config/nvim/plugin/packer_compiled.lua create mode 100644 .config/nvim/plugin/php-doc.lua create mode 100644 .config/nvim/plugin/telescope.lua create mode 100644 .config/nvim/plugin/tmux.lua delete mode 100644 .config/nvim/telescope.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..13a6964 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,11 @@ + +-- General options and remaps +require('general.options') +require('general.remaps') +require('general.autocmd') + +-- Helper functions +require('helper.toggle-tab-width') + +-- Plugins +require('packer-plugins') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index d46c7c7..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,241 +0,0 @@ -" My awesome vimrc - -let mapleader ="," - -if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) - echo "Downloading junegunn/vim-plug to manage plugins..." - silent !mkdir -p ~/.config/nvim/autoload/ - silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim - autocmd VimEnter * PlugInstall -endif - -function! Cond(cond, ...) - let opts = get(a:000, 0, {}) - return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) -endfunction - -call plug#begin('~/.config/nvim/plugged') - -Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode')) - -Plug 'nvim-lua/popup.nvim', Cond(!exists('g:vscode')) -Plug 'nvim-lua/plenary.nvim', Cond(!exists('g:vscode')) -Plug 'nvim-telescope/telescope.nvim', Cond(!exists('g:vscode')) -Plug 'nvim-telescope/telescope-fzy-native.nvim', Cond(!exists('g:vscode')) - -Plug 'Rican7/php-doc-modded' - -Plug 'udalov/kotlin-vim' -Plug 'f-person/git-blame.nvim' - -Plug 'vimwiki/vimwiki', Cond(!exists('g:vscode')) - -Plug 'ap/vim-css-color', Cond(!exists('g:vscode')) - -Plug 'dart-lang/dart-vim-plugin' - -Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } -Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } - -call plug#end() - -" Some basics: -set clipboard+=unnamedplus -set nohlsearch -set incsearch -set ignorecase - -autocmd BufWritePre * :%s/\s\+$//e -set go=a -set mouse=a -set smartcase -set linebreak - -set noswapfile -set nobackup -set undodir=~/.config/nvim/undodir -set undofile - -nnoremap c "_c -set nocompatible -filetype plugin on -syntax on -set encoding=utf-8 -set number relativenumber - -autocmd BufWritePre * :%s/\s\+$//e - -nnoremap vs :vsplit -nnoremap hs :split - -" Tab 2 spaces -filetype plugin indent on -set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab - -let g:tabStop=4 -function! ToggleTabWidth() - if g:tabStop == 2 - set tabstop=4 softtabstop=4 shiftwidth=4 - let g:tabStop=4 - else - set tabstop=2 softtabstop=2 shiftwidth=2 - let g:tabStop=2 - endif -endfunction - -nnoremap t :call ToggleTabWidth() - -autocmd BufNewFile,BufRead *.dart setlocal tabstop=2 softtabstop=2 shiftwidth=2 -autocmd BufNewFile,BufRead *.dart let g:tabStop=2 - -" Disables automatic commenting on newline: -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o - -nnoremap t :call ToggleTabWidth() - -" Disables automatic commenting on newline: -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o - -" Remember last cursor position -autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif - -" Automatically save the current session whenever vim is closed -autocmd VimLeave * mksession! ~/.config/nvim/session/shutdown_session.vim - -" restores that 'shutdown session' -noremap :source ~/.config/nvim/session/shutdown_session.vim - -" If you really want to, this next line should restore the shutdown session -" automatically, whenever you start vim. (Commented out for now, in case -" somebody just copy/pastes this whole block) -" -" autocmd VimEnter source ~/.vim/shutdown_session.vim - -" manually save a session with -noremap :mksession! ~/.config/nvim/session/manual_session.vim - -" recall the manually saved session with -noremap :source ~/.config/nvim/session/manual_session.vim - -" Copy entire document -noremap y ggyG -map y ggyG - -" Set gohtml template files to html syntax -autocmd BufNewFile,BufRead *.gohtml set syntax=html - -nnoremap 1 1gt -nnoremap 2 2gt -nnoremap 3 3gt -nnoremap 4 4gt -nnoremap 5 5gt - -" NETRW - -let g:netrw_liststyle = 3 -let g:netrw_banner = 0 -let g:netrw_browse_split = 4 -let g:netrw_winsize = 20 -let g:netrw_altv = 1 - -let g:NetrwIsOpen=0 -function! ToggleNetrw() - if g:NetrwIsOpen - let i = bufnr("$") - while (i >= 1) - if (getbufvar(i, "&filetype") == "netrw") - silent exe "bwipeout " . i - endif - let i-=1 - endwhile - let g:NetrwIsOpen=0 - else - let g:NetrwIsOpen=1 - silent Lexplore - endif -endfunction - -" Add your own mapping. For example: -noremap :call ToggleNetrw() - -" coc -highlight CocErrorSign ctermfg=Black ctermbg=Magenta - -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -nmap gd (coc-definition) -nmap gr (coc-references) -nmap rr (coc-rename) -nnoremap prw :CocSearch =expand("") - -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" - - -" PHP Doc - -nnoremap h :call UpdatePhpDocIfExists() -function! UpdatePhpDocIfExists() - normal! k - if getline('.') =~ '/' - normal! V%d - else - normal! j - endif - call PhpDocSingle() - normal! k^%k$ - if getline('.') =~ ';' - exe "normal! $svoid" - endif -endfunction - -nnoremap :call UpdatePhpDocIfExists() - -" VimWiki -au filetype vimwiki silent! iunmap - -try - nmap ej :call CocAction('diagnosticNext') - nmap ek :call CocAction('diagnosticPrevious') -endtry - -" Telescope remaps -lua require("telescope") - -nnoremap :lua require('telescope.builtin').grep_string({ search = vim.fn.input("Grep For > ")}) -nnoremap :lua require('telescope.builtin').git_files() -nnoremap :lua require('telescope.builtin').find_files() - -nnoremap fb lua require('telescope.builtin').buffers() - -" Spell-check -map o :setlocal spell! spelllang=en_au - -" Shortcutting split navigation, saving a keypress: -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -" Replace all is aliased to S. -nnoremap :%s//g - -" Navigating with guides -inoremap /<++>"_c4l -vnoremap /<++>"_c4l -map /<++>"_c4l - -augroup twig_ft -au! -autocmd BufNewFile,BufRead *.docker set syntax=dockerfile -augroup END - diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..e64256e --- /dev/null +++ b/.config/nvim/lua/autocmd.lua @@ -0,0 +1,33 @@ + +-- Remove any trailing whitespace from the file on write +vim.api.nvim_create_autocmd({ 'BufWritePre' }, { command = [[%s/\s\+$//e]] }) + +-- Load file on last line +-- TODO: change this to use lua +vim.api.nvim_create_autocmd({ 'BufRead' }, { + command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]] +}) + +-- Save session on VimLeave +vim.api.nvim_create_autocmd({ 'VimLeave' }, { + command = [[mksession! ~/.config/nvim/session/shutdown_session.vim]] +}) + +-- Set tabs to 2 for dart, vue, and js files +vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, { + pattern = { '*.dart', '*.vue', '*.js' }, + callback = function() + vim.o.tabstop = 2 + vim.o.softtabstop = 2 + vim.o.shiftwidth = 2 + end +}) + +-- Ensure to read .docker files as a dockerfile +vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, { + pattern = { '*.docker' }, + callback = function() + vim.o.syntax = 'dockerfile' + end +}) + diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..07aef10 --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,30 @@ +vim.g.mapleader = ',' + +vim.o.clipboard = 'unnamedplus' + +vim.o.nohlsearch = true +vim.o.incsearch = true +vim.o.ignorecase = true + +-- autocmd BufWritePre * :%s/\s\+$//e + +vim.o.mouse = 'a' +vim.o.smartcase = true +vim.o.linebreak = true + +vim.o.noswapfile = true +vim.o.nobackup = true +vim.o.undodir = vim.fn.expand('~/.config/nvim/undodir') +vim.o.undofile = true + +vim.o.encoding = 'utf-8' +vim.o.number = true +vim.o.relativenumber = true + +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.expandtab = true +vim.o.shiftwidth = 4 +vim.o.smarttab = true + +vim.o.formatoptions = 'tqj' diff --git a/.config/nvim/lua/packer-plugins.lua b/.config/nvim/lua/packer-plugins.lua new file mode 100644 index 0000000..a4c2099 --- /dev/null +++ b/.config/nvim/lua/packer-plugins.lua @@ -0,0 +1,25 @@ +return require('packer').startup(function() + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- colorscheme + use 'gruvbox-community/gruvbox' + + use { 'neoclide/coc.nvim', run = 'yarn install' } + + use 'nvim-lua/popup.nvim' + use 'nvim-lua/plenary.nvim' + use 'nvim-telescope/telescope.nvim' + use 'nvim-telescope/telescope-fzy-native.nvim' + + use 'Rican7/php-doc-modded' + + use 'f-person/git-blame.nvim' + + use 'dart-lang/dart-vim-plugin' + + use { 'fatih/vim-go', cmd = 'GoUpdateBinaries' } + use { 'darrikonn/vim-gofmt', cmd = 'GoUpdateBinaries' } + + use 'aserowy/tmux.nvim' +end) diff --git a/.config/nvim/lua/remaps.lua b/.config/nvim/lua/remaps.lua new file mode 100644 index 0000000..5ba2a80 --- /dev/null +++ b/.config/nvim/lua/remaps.lua @@ -0,0 +1,35 @@ +local options = { noremap = true } + +vim.api.nvim_set_keymap('n', 'c', '"_c', options) + +-- Easily open splits +vim.api.nvim_set_keymap('n', 'hs', 'split', options) +vim.api.nvim_set_keymap('n', 'vs', 'vsplit', options) + +-- Copy the entire file +vim.api.nvim_set_keymap('n', 'y', 'ggyG', options) + +-- Easily navigate tabs +vim.api.nvim_set_keymap('n', '1', '1gt', options) +vim.api.nvim_set_keymap('n', '2', '2gt', options) +vim.api.nvim_set_keymap('n', '3', '3gt', options) +vim.api.nvim_set_keymap('n', '4', '4gt', options) +vim.api.nvim_set_keymap('n', '5', '5gt', options) + +-- Manually store session +vim.api.nvim_set_keymap('n', '', 'mksession! ~/.config/nvim/session/manual_session.vim', options) +-- Restore manually stored session +vim.api.nvim_set_keymap('n', '', 'source ~/.config/nvim/session/manual_session.vim', options) +-- Restore auto saved session created on exit +vim.api.nvim_set_keymap('n', '', 'source ~/.config/nvim/session/shutdown_session.vim', options) + +-- Replace all is aliased to S. +vim.api.nvim_set_keymap('n', '', '%s//g', options) + +-- Navigating with guides +vim.api.nvim_set_keymap('n', '', '/<++>"_c4l', options) +vim.api.nvim_set_keymap('i', '', '/<++>"_c4l', options) +vim.api.nvim_set_keymap('v', '', '/<++>"_c4l', options) + +-- Spell-check +vim.api.nvim_set_keymap('n', 'o', 'setlocal spell! spelllang=en_au', options) diff --git a/.config/nvim/plugin/coc.lua b/.config/nvim/plugin/coc.lua new file mode 100644 index 0000000..265416c --- /dev/null +++ b/.config/nvim/plugin/coc.lua @@ -0,0 +1,21 @@ +vim.o.signcolumn = 'number' + +-- Bind tab to select next tab complete +vim.api.nvim_set_keymap("i", "", "pumvisible() ? '' : ''", {noremap = true, silent = true, expr = true}) + +vim.api.nvim_set_keymap("n", ".", "(coc-codeaction)", {}) +vim.api.nvim_set_keymap("n", "l", ":CocCommand eslint.executeAutofix", {}) +vim.api.nvim_set_keymap("n", "gd", "(coc-definition)", {silent = true}) +vim.api.nvim_set_keymap("n", "gr", "(coc-references)", {silent = true}) +vim.api.nvim_set_keymap("n", "K", ":call CocActionAsync('doHover')", {silent = true, noremap = true}) +vim.api.nvim_set_keymap("n", "rn", "(coc-rename)", {}) +vim.api.nvim_set_keymap("n", "f", ":CocCommand prettier.formatFile", {noremap = true}) + +vim.api.nvim_set_keymap("n", "g[", ":call CocActionAsync('diagnosticPrevious')", {silent = true, noremap = true}) +vim.api.nvim_set_keymap("n", "g]", ":call CocActionAsync('diagnosticNext')", {silent = true, noremap = true}) + +vim.keymap.set("n", "", vim.fn['coc#refresh'](), {silent = true, noremap = true}) + +-- Bind Ctrl + j,k to up and down for COC completion +vim.api.nvim_set_keymap('i', '', "pumvisible() ? '' : ''", { noremap = true, expr = true, silent = true }) +vim.api.nvim_set_keymap('i', '', "pumvisible() ? '' : ''", { noremap = true, expr = true, silent = true }) diff --git a/.config/nvim/plugin/gruvbox.lua b/.config/nvim/plugin/gruvbox.lua new file mode 100644 index 0000000..e387281 --- /dev/null +++ b/.config/nvim/plugin/gruvbox.lua @@ -0,0 +1 @@ +vim.cmd[[colorscheme gruvbox]] diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..d8d5d7c --- /dev/null +++ b/.config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,159 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + + local time + local profile_info + local should_profile = false + if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end + else + time = function(chunk, start) end + end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + + _G._packer = _G._packer or {} + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/home/tovi/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tovi/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tovi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tovi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/tovi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["coc.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/coc.nvim", + url = "https://github.com/neoclide/coc.nvim" + }, + ["dart-vim-plugin"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/dart-vim-plugin", + url = "https://github.com/dart-lang/dart-vim-plugin" + }, + ["git-blame.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/git-blame.nvim", + url = "https://github.com/f-person/git-blame.nvim" + }, + gruvbox = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/gruvbox", + url = "https://github.com/gruvbox-community/gruvbox" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["php-doc-modded"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/php-doc-modded", + url = "https://github.com/Rican7/php-doc-modded" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["popup.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/popup.nvim", + url = "https://github.com/nvim-lua/popup.nvim" + }, + ["telescope-fzy-native.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/telescope-fzy-native.nvim", + url = "https://github.com/nvim-telescope/telescope-fzy-native.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["tmux.nvim"] = { + loaded = true, + path = "/home/tovi/.local/share/nvim/site/pack/packer/start/tmux.nvim", + url = "https://github.com/aserowy/tmux.nvim" + }, + ["vim-go"] = { + commands = { "GoUpdateBinaries" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tovi/.local/share/nvim/site/pack/packer/opt/vim-go", + url = "https://github.com/fatih/vim-go" + }, + ["vim-gofmt"] = { + commands = { "GoUpdateBinaries" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tovi/.local/share/nvim/site/pack/packer/opt/vim-gofmt", + url = "https://github.com/darrikonn/vim-gofmt" + } +} + +time([[Defining packer_plugins]], false) + +-- Command lazy-loads +time([[Defining lazy-load commands]], true) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file GoUpdateBinaries lua require("packer.load")({'vim-go', 'vim-gofmt'}, { cmd = "GoUpdateBinaries", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +time([[Defining lazy-load commands]], false) + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end diff --git a/.config/nvim/plugin/php-doc.lua b/.config/nvim/plugin/php-doc.lua new file mode 100644 index 0000000..7bfee69 --- /dev/null +++ b/.config/nvim/plugin/php-doc.lua @@ -0,0 +1,7 @@ +vim.keymap.set('n', '', function () + if vim.bo.filetype ~= 'php' then + return + end + + vim.api.nvim_call_function("PhpDocSingle", {}) +end, options) diff --git a/.config/nvim/plugin/telescope.lua b/.config/nvim/plugin/telescope.lua new file mode 100644 index 0000000..fd2025c --- /dev/null +++ b/.config/nvim/plugin/telescope.lua @@ -0,0 +1,60 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local previewers = require("telescope.previewers") +local action_state = require("telescope.actions.state") +local conf = require("telescope.config").values +local actions = require("telescope.actions") + +require("telescope").setup({ + defaults = { + file_sorter = require("telescope.sorters").get_fzy_sorter, + prompt_prefix = " >", + color_devicons = true, + + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + + mappings = { + i = { + [""] = false, + [""] = actions.send_to_qflist, + }, + }, + }, +}) + +local M = {} + +function git_branches () + require("telescope.builtin").git_branches({ + attach_mappings = function(_, map) + map("i", "", actions.git_delete_branch) + map("n", "", actions.git_delete_branch) + return true + end, + }) +end + +local options = { noremap = true } + +vim.keymap.set('n', '', function() + local term = vim.fn.input("Grep For > ") + if term == '' then + return + end + require('telescope.builtin').grep_string({ search = term }) +end, options) + +vim.keymap.set('n', '', function() + local ran, errorMessage = pcall(require('telescope.builtin').git_files) + if not ran then + require('telescope.builtin').find_files() + end +end, options) + +-- vim.keymap.set('n', '', function() +-- end, options) + +vim.keymap.set('n', 'fb', require('telescope.builtin').buffers, options) + diff --git a/.config/nvim/plugin/tmux.lua b/.config/nvim/plugin/tmux.lua new file mode 100644 index 0000000..da0ec7e --- /dev/null +++ b/.config/nvim/plugin/tmux.lua @@ -0,0 +1,17 @@ +require("tmux").setup({ + -- overwrite default configuration + -- here, e.g. to enable default bindings + copy_sync = { + -- enables copy sync and overwrites all register actions to + -- sync registers *, +, unnamed, and 0 till 9 from tmux in advance + enable = true, + }, + navigation = { + -- enables default keybindings (C-hjkl) for normal mode + enable_default_keybindings = true, + }, + resize = { + -- enables default keybindings (A-hjkl) for normal mode + enable_default_keybindings = true, + } + }) diff --git a/.config/nvim/telescope.lua b/.config/nvim/telescope.lua deleted file mode 100644 index 39292f5..0000000 --- a/.config/nvim/telescope.lua +++ /dev/null @@ -1,27 +0,0 @@ -local actions = require('telescope.actions') -require('telescope').setup { - defaults = { - file_sorter = require('telescope.sorters').get_fzy_sorter, - prompt_prefix = ' >', - color_devicons = true, - - file_previewer = require('telescope.previewers').vim_buffer_cat.new, - grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, - qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, - - mappings = { - i = { - [""] = false, - [""] = actions.send_to_qflist, - }, - } - }, - extensions = { - fzy_native = { - override_generic_sorter = false, - override_file_sorter = true, - } - } -} - -require('telescope').load_extension('fzy_native') diff --git a/update.sh b/update.sh index b6c8261..cbf24a3 100755 --- a/update.sh +++ b/update.sh @@ -9,9 +9,11 @@ declare -a FILES=( .iterm2_shell_integration.bash .xinitrc .config/aliasrc - .config/nvim/init.vim + .config/nvim/init.lua + .config/nvim/lua/general + .config/nvim/plugin + .config/nvim/lua/packer-plugins.lua .config/nvim/coc-settings.json - .config/nvim/telescope.lua .config/lf/ .dwm/autostart.sh .dwm/dwm-sss