-- Blallo neovim configuration local g = vim.g local cmd = vim.cmd local o, wo, bo = vim.o, vim.wo, vim.bo local utils = require 'config.utils' local opt = utils.opt -- local autocmd = utils.autocmd -- local map = utils.map local let = utils.let local tilde = os.getenv('HOME') -- Copied from https://medium.com/geekculture/neovim-configuration-for-beginners-b2116dbbde84 opt('compatible', false) opt('showmatch', true) opt('ignorecase', true) opt('hlsearch', true) opt('incsearch', true) opt('tabstop', 4) opt('softtabstop', 4) opt('expandtab', true) opt('shiftwidth', 4) opt('textwidth', 0) opt('autoindent', true) opt('number', true) opt('wildmode', 'longest,list') opt('cc', '88') cmd [[filetype plugin indent on]] opt('smartindent', true, buffer) cmd [[syntax on]] opt('clipboard', 'unnamedplus') cmd [[filetype plugin on]] opt('cursorline', true) opt('ttyfast', true) opt('hidden', true) opt('termguicolors', true) opt('autoread', true) -- opt('mouse', v) -- opt('mouse', a) -- opt('spell', true) -- Configure swap opt('swapfile', true) opt('directory', tilde .. '/.cache/nvim/swap') -- Configure backup opt('backupdir', tilde .. '/.cache/nvim/backup') -- Configure undo opt('undofile', true) opt('undodir', tilde .. '/.cache/nvim/undo') opt('undolevels', 1000) opt('undoreload', 100000) -- cmd([[set listchars=tab:›\ ,trail:•,extends:#,nbsp:.•]]) -- set showbreak=↪\ cmd([[ set listchars=tab:›\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨ set list ]]) cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost plugins.lua source | PackerCompile augroup end ]]) -- Reopen file to last cursor position, if possible cmd([[ if has("autocmd") au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif endif ]]) cmd [[command! WhatHighlight :call util#syntax_stack()]] cmd [[command! PackerInstall packadd packer.nvim | lua require('plugins').install()]] cmd [[command! PackerUpdate packadd packer.nvim | lua require('plugins').update()]] cmd [[command! PackerSync packadd packer.nvim | lua require('plugins').sync()]] cmd [[command! PackerClean packadd packer.nvim | lua require('plugins').clean()]] cmd [[command! PackerCompile packadd packer.nvim | lua require('plugins').compile()]] -- issue with python 3.10 (https://github.com/neovim/neovim/issues/14586) -- g.python3_host_prog = '/usr/bin/python3' -- Colortheme require('config.theme') -- Treesitter configuration require('config.treesitter') -- LSP configuration require('config.lspconfig') -- project.nvim require('config.project_nvim') -- Custom Custom = require('config.custom') cmd([[ au BufRead,BufNewFile *.ha set filetype=hare au BufRead,BufNewFile *.conf set filetype=config ]]) g["do_filetype_lua"] = 1 -- Keybinds let(nil, 'mapleader', ',') Mapper = require("nvim-mapper") local map = Mapper.map -- - Telescope-related local opts = { noremap = true, silent = true } map('n', 'ff', 'Telescope find_files', opts, "Telescope", "find_files", "Find files from current position") map('n', 'fg', 'Telescope git_files', opts, "Telescope", "git_files", "Find git-tracked files") map('n', 'fb', 'Telescope buffers', opts, "Telescope", "buffers", "Search in current opened buffers") map('n', 'fc', 'Telescope grep_string', opts, "Telescope", "grep_string", "Search string from current position") map('n', 'fr', 'Telescope live_grep', opts, "Telescope", "live_grep", "Search string in real time") map('n', 'fR', 'Telescope live_grep grep_open_files=true', opts, "Telescope", "live_grep_open_buffers", "Search string in real time (only on the open buffers)") map('n', 'ft', 'Telescope treesitter', opts, "Telescope", "treesitter", "Explore treesitter") map('n', 'fC', 'Telescope git_bcommits', opts, "Telescope", "git_bcommits", "Show diff of current buffer") map('n', 'fh', 'Telescope builtin', opts, "Telescope", "builtin", "Show Telescope builtins") map('n', 'lr', 'Telescope lsp_references', opts, "Telescope", "lsp_references", "Show references using LSP") map('n', 'li', 'Telescope lsp_implementations', opts, "Telescope", "lsp_implementations", "Show implementations using LSP") map('n', 'ld', 'Telescope lsp_definitions', opts, "Telescope", "lsp_definitions", "Show definitions using LSP") map('n', 'ls', 'Telescope lsp_document_symbols', opts, "Telescope", "lsp_document_symbols", "Show symbols in document using LSP") -- Undo tree map('n', 'u', 'UndotreeToggleUndotreeFocus', { noremap = true }, "UndoTree", "undo_tree_toggle" , "Toggle UndoTree browser") -- Split maximizer map('n', 'mm', 'MaximizerToggle', opts, "MaximizerToggle", "maximizer_toggle_n", "Toggle maximal view of current split") map('v', 'mm', 'MaximizerToggle', opts, "MaximizerToggle", "maximizer_toggle_v", "Toggle maximal view of current split") -- Split movement and management map('n', '', 'l', opts, "Movement", "move_right_n", "Move to the split to the right") map('v', '', 'l', opts, "Movement", "move_right_v", "Move to the split to the right") map('i', '', 'l', opts, "Movement", "move_right_i", "Move to the split to the right") map('n', '', 'k', opts, "Movement", "move_up_n", "Move to the upper split") map('v', '', 'k', opts, "Movement", "move_up_v", "Move to the upper split") map('i', '', 'k', opts, "Movement", "move_up_i", "Move to the upper split") map('n', '', 'j', opts, "Movement", "move_down_n", "Move to the lower split") map('v', '', 'j', opts, "Movement", "move_down_v", "Move to the lower split") map('i', '', 'j', opts, "Movement", "move_down_i", "Move to the lower split") map('n', '', 'h', opts, "Movement", "move_left_n", "Move to the split to the left") map('v', '', 'h', opts, "Movement", "move_left_v", "Move to the split to the left") map('i', '', 'h', opts, "Movement", "move_left_i", "Move to the split to the left") map('n', '', 'bd', opts, "Management", "full_close_n", "Close current split and associated buffer") map('v', '', 'bd', opts, "Management", "full_close_v", "Close current split and associated buffer") map('i', '', 'bd', opts, "Management", "full_close_i", "Close current split and associated buffer") map('n', '', 'bnext', {}, "Movement", "go_to_next_buf", "Switch to the next buffer") map('n', '\\', 'bprev', {}, "Movement", "go_to_prev_buf", "Switch to the previous buffer") -- Search niceties map('v', '/', ':\\%V', {}, "Search", "search_in_visual_selection", "Search only in the current visual selection") -- Move selection around cmd([[ nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi inoremap :m .-2==gi vnoremap :m '>+1gv=gv vnoremap :m '<-2gv=gv ]]) -- map('n', '', 'm .+1==', opts, "MoveText", "move_text_up_n", "") -- map('n', '', 'm .-2==', opts, "MoveText", "move_text_down_n", "") -- map('i', '', 'm .+1==gi', opts, "MoveText", "move_text_up_i", "") -- map('i', '', 'm .-2==gi', opts, "MoveText", "move_text_down_i", "") -- map('v', '', "m '>+1gv=gv", opts, "MoveText", "move_text_up_v", "") -- map('v', '', "m '<-2gv=gv", opst, "MoveText", "move_text_down_v", "") -- Clean highlight map('n', '', 'nohlscall clearmatches()', opts, "CleanHighlights", "clear_all", "Clear all highlights and matches") -- Open links with reader map('n', 'gx', 'lua Custom.open_with_reader()', {}, "OpenWithReader", "open_with_reader", "Open the link under the cursor with `reader` in a floating tab") -- cder map('n', 'cd', 'Telescope cder', {}, "Cder", "cder", "Change base directory interactively") -- vgit require('config.vgit') -- coc require('config.coc') -- black require('config.black') -- structural search and replace vim.keymap.set({ "n", "x" }, "sr", function() require("ssr").open() end)