From a8903ac96dd7cd0e1af968d729e557d579f26124 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Fri, 8 Oct 2021 00:09:37 +0300 Subject: neovim: migrate to init.lua --- .config/nvim/lua/mappings.lua | 131 +++++++++++++++++++++++++++++++++ .config/nvim/lua/plugin_settings.lua | 126 ++++++++++++++++++++++++++++++++ .config/nvim/lua/plugins.lua | 136 +++++++++++++++++++++++++++++++++++ .config/nvim/lua/settings.lua | 103 ++++++++++++++++++++++++++ 4 files changed, 496 insertions(+) create mode 100644 .config/nvim/lua/mappings.lua create mode 100644 .config/nvim/lua/plugin_settings.lua create mode 100644 .config/nvim/lua/plugins.lua create mode 100644 .config/nvim/lua/settings.lua (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..fe59a99 --- /dev/null +++ b/.config/nvim/lua/mappings.lua @@ -0,0 +1,131 @@ +-- ┌──────────────────┐ +-- │ ▗ │ +-- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ +-- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ +-- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ +-- └──────────────────┘ +-- ┌────────────────────────┐ +-- │ ▗ │ +-- │▛▚▀▖▝▀▖▛▀▖▛▀▖▄ ▛▀▖▞▀▌▞▀▘│ +-- │▌▐ ▌▞▀▌▙▄▘▙▄▘▐ ▌ ▌▚▄▌▝▀▖│ +-- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ +-- └────────────────────────┘ + +-- map helper +local function map(mode, lhs, rhs, opts) + local options = {noremap = true, silent = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +-- local map = vim.api.nvim_set_keymap +local cmd = vim.cmd +local M = {} + +-- brute force deasciify everything +map('n', 'tc', 'TurkishDeasciifyForce()', {expr = true}) +map('x', 'tc', 'TurkishDeasciifyForce()', {expr = true}) +map('n', 'tctc', "TurkishDeasciifyForce() .. '_'", {expr = true}) + +-- use turkish-mode to selectively deasciify +map('n', 'tr', 'TurkishDeasciify()', {expr = true}) +map('x', 'tr', 'TurkishDeasciify()', {expr = true}) +map('n', 'trtr', "TurkishDeasciify() .. '_'", {expr = true}) + +-- ascii everything +map('n', 'rt', 'TurkishAsciify()', {expr = true}) +map('x', 'rt', 'TurkishAsciify()', {expr = true}) +map('n', 'rtrt', "TurkishAsciify() .. '_'", {expr = true}) + +-- https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump +-- search & highlight but do not jump +map('n', '*', ':keepjumps normal! mi*`i') +map('n', '#', ':keepjumps normal! mi#`i ') + +-- Save file as sudo on files that require root permission +map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!') + +-- replace ex mode with gq (format lines) +map('n', 'Q', 'gq') + +-- set formatprg to sentences, for prose +map('n', 'fp', ":set formatprg=~/.local/bin/sentences") + +-- Replace all is aliased to S. +map('n', 'S', ':%s//g') + +-- If you like "Y" to work from the cursor to the end of line (which is more +-- logical, but not Vi-compatible) +map('n', 'Y', 'y$') + +-- jump to buffer +map('n', 'b', ':ls:b') + +-- Up and down are more logical with g.. +map('n', 'k', 'gk') +map('n', 'j', 'gj') +map('i', '', 'gka') +map('i', '', 'gja') + +-- Disable highlight when is pressed +map('n', '', ':noh') +-- Space used to toggle folds, now it's x (because x is d) +map('n', '', '"_x') + +-- separate cut and delete +map('n', 'x', 'd') +map('x', 'x', 'd') +map('n', 'xx', 'dd') +map('n', 'X', 'D') + +-- change into pwd of current directory +map('n', 'cd', ':cd %:p:h:pwd') + +-- press \g and start writing prose +map('n', 'g', ':Goyo') + +-- plug mappings {{{1 -- + +-- mappings should not be noremap +-- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ +local function plugmap(mode, lhs, rhs, opts) + local options = {noremap = false, silent = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +-- sneak using grave, s is for sandwich +plugmap('n', '`', 'Sneak_s') +plugmap('n', '`', 'Sneak_s') +plugmap('n', '`', 'Sneak_S') +plugmap('n', "'", '`') + +-- use the special yoink paste that rotates +plugmap('n', 'p', '(YoinkPaste_p)') +plugmap('n', 'P', '(YoinkPaste_P)') + +-- substitute from yank +plugmap('n', 'ys', '(SubversiveSubstitute)') +plugmap('n', 'yss', '(SubversiveSubstituteLine)') +plugmap('n', 'yS', '(SubversiveSubstituteToEndOfLine)') + +-- substitute over range +plugmap('n', 's', '(SubversiveSubstituteRange)') +plugmap('x', 's', '(SubversiveSubstituteRange)') +plugmap('n', 'ss', '(SubversiveSubstituteWordRange)') + +-- subvert over range +plugmap('n', 's', '(SubversiveSubvertRange)') +plugmap('x', 's', '(SubversiveSubvertRange)') +plugmap('n', 'ss', '(SubversiveSubvertWordRange)') + +-- iterate over yank list +plugmap('n', '', '(YoinkPostPasteSwapBack)') +plugmap('n', '', '(YoinkPostPasteSwapForward)') + +-- insert mode completion +plugmap('i', '', '(fzf-complete-word)') +plugmap('i', '', '(fzf-complete-path)') +plugmap('i', '', '(fzf-complete-line)') + +-- 1}}} -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua new file mode 100644 index 0000000..6de7ebd --- /dev/null +++ b/.config/nvim/lua/plugin_settings.lua @@ -0,0 +1,126 @@ +-- ┌──────────────────┐ +-- │ ▗ │ +-- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ +-- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ +-- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ +-- └──────────────────┘ +-- ┌─────────────────────────────────────┐ +-- │ ▜ ▐ ▐ ▗ │ +-- │▛▀▖▐ ▌ ▌▞▀▌▗▖▖▞▀▘▞▀▖▜▀ ▜▀ ▄ ▛▀▖▞▀▌▞▀▘│ +-- │▙▄▘▐ ▌ ▌▚▄▌▘▝ ▝▀▖▛▀ ▐ ▖▐ ▖▐ ▌ ▌▚▄▌▝▀▖│ +-- │▌ ▘▝▀▘▗▄▘ ▀▀ ▝▀▘ ▀ ▀ ▀▘▘ ▘▗▄▘▀▀ │ +-- └─────────────────────────────────────┘ + +local g = vim.g -- global for let options +local opt = vim.opt -- convenient :set +local cmd = vim.cmd -- vim commands + +-- vimwiki {{{ -- +g.vimwiki_list = { + { + path = '/home/yigit/nextcloud/personal_wiki/text', + path_html = '/home/yigit/nextcloud/personal_wiki/html', + auto_generate_tags = 1, + automatic_nested_syntaxes = 1, + template_path = '/home/yigit/nextcloud/personal_wiki/templates', + template_default = 'default_template', + template_ext = '.html', + auto_export = 1, + auto_tags = 1 + } +} + +g.vimwiki_global_ext = 0 +g.vimwiki_hl_headers = 1 +-- }}} vimwiki -- + +-- lualine {{{ -- +require'lualine'.setup { + options = { + lower = true, + icons_enabled = true, + theme = 'rose-pine', + section_separators = {'', ''}, + component_separators = {'', ''}, + disabled_filetypes = {} + }, + sections = { + lualine_a = {{'mode', lower = true}}, + lualine_b = {'branch', 'diff'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = { + 'location', { + 'diagnostics', + sources = {'ale'}, + sections = {'error', 'warn', 'info', 'hint'}, + symbols = {error = 'e', warn = 'w', info = 'i', hint = 'h'} + } + } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} +} +-- }}} requi -- + +-- Cutlass suite {{{1 -- + +-- cutlass/yoink/subverse suite +g.yoinkIncludeDeleteOperations = 1 + +-- fix the Target STRING not available +g.clipboard = { + name = 'xsel_override', + copy = { + ['+'] = 'xsel --input --clipboard', + ['*'] = 'xsel --input --primary', + }, + paste = { + ['+'] = 'xsel --output --clipboard', + ['*'] = 'xsel --output --primary', + }, + cache_enabled = 1, +} + +-- 1}}} -- + +-- UltiSnips {{{ -- +opt.runtimepath:append('/home/yigit/.vim/my-snippets/') +g.UltiSnipsEditSplit = "vertical" +-- ctrl + l expands the snippet, c + j/k navigates placeholders +g.UltiSnipsExpandTrigger = "" +g.UltiSnipsEnableSnipMate = "1" +-- }}} UltiSnips -- + +-- float preview +g["float_preview#docked"] = 0 + +-- highlight on yank +cmd('highlight HighlightedyankRegion cterm=reverse gui=reverse') +g.highlightedyank_highlight_duration = 200 + +-- beacon {{{ -- +g.beacon_size = 100 +g.beacon_shrink = 1 +cmd('highlight Beacon guibg=red ctermbg=15') +-- }}} beacon -- + +-- vim-slime {{{ -- +g.slime_target = "tmux" +g.slime_paste_file = "/home/yigit/.slime_paste" +-- g.slime_default_config = {socket_name = get(split($TMUX, ","), 0), target_pane = "{last}"} +-- }}} vim-slime -- + +-- vimtex {{{ -- +g.vimtex_view_method = 'zathura' +g.vimtex_quickfix_mode = 0 +-- }}} vimtex -- diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..58cccbc --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,136 @@ +-- ┌───────────────────┐ +-- │ ▜ ▗ │ +-- │▛▀▖▐ ▌ ▌▞▀▌▄ ▛▀▖▞▀▘│ +-- │▙▄▘▐ ▌ ▌▚▄▌▐ ▌ ▌▝▀▖│ +-- │▌ ▘▝▀▘▗▄▘▀▘▘ ▘▀▀ │ +-- └───────────────────┘ + +return require('packer').startup(function() + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- latex suite + use {'lervag/vimtex', ft = {'tex', 'latex', 'plaintext'}} + + -- still here + use 'dense-analysis/ale' + -- manages tag files + use 'ludovicchabant/vim-gutentags' + -- run tests (todo: write tests) + use 'janko/vim-test' + -- type in file send to repl + use 'jpalardy/vim-slime' + -- snippets to expand + use {'SirVer/ultisnips', 'honza/vim-snippets'} + -- Highlight the yanked region + use 'machakann/vim-highlightedyank' + + -- auto pair plugin, people hate these + use 'tmsvg/pear-tree' + -- git diff in the sign column + use 'airblade/vim-gitgutter' + -- completion preview of floating window + use 'ncm2/float-preview.nvim' + + -- language packs + use 'sheerun/vim-polyglot' + -- i3 config syntax + use 'mboughaba/i3config.vim' + -- kitty config filetype + use 'fladson/vim-kitty' + + use{'junegunn/fzf', dir = '~/.fzf'} + use 'junegunn/fzf.vim' + + -- file explorer + use 'lambdalisue/fern.vim' + -- bug in neovim, so required for now + -- https://github.com/lambdalisue/fern.vim/issues/120 + use 'antoinemadec/FixCursorHold.nvim' + + -- displays tags ordered by scope + use 'majutsushi/tagbar' + -- Undo tree + use { + 'mbbill/undotree', + cmd = 'UndotreeToggle', + config = [[vim.g.undotree_SetFocusWhenToggle = 1]], + } + -- Highlight colors + use { + 'norcalli/nvim-colorizer.lua', + ft = { 'css', 'javascript', 'vim', 'html' }, + config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], + } + + -- cutlass suite, x, d, \ys etc. + use { + 'svermeulen/vim-cutlass', + 'svermeulen/vim-subversive', + 'svermeulen/vim-yoink' + } + + -- Personal wiki + use 'vimwiki/vimwiki' + -- centers the writing + use 'junegunn/goyo.vim' + -- highlights the current paragraph + use 'junegunn/limelight.vim' + -- change ASCII text to Turkish text + use 'yigitsever/turkish-deasciifier.vim' + + -- text alignment \w :Tab + use 'godlygeek/tabular' + -- move selections up and down with alt+[j,k] + use 'matze/vim-move' + -- surround text objects; sa, sr and sd + use 'machakann/vim-sandwich' + -- provide additional text objects + use 'wellle/targets.vim' + -- indentation level text object, ia, ii + use 'michaeljsmith/vim-indent-object' + -- visual feedback for substitute holy shit this is amazing + use 'markonm/traces.vim' + -- see the contents of registers on "/ + use 'junegunn/vim-peekaboo' + -- use k to highlight multiple words) + use 'lfv89/vim-interestingwords' + -- swap delimited items using g>, g< + use 'machakann/vim-swap' + -- jump to location by 2 characters, ` + use 'justinmk/vim-sneak' + -- reopen files at your last edit position + use 'farmergreg/vim-lastplace' + -- flash cursor on jump + use 'DanilaMihailov/beacon.nvim' + + -- cursorline of the $CURRENT_YEAR + use { + 'hoob3rt/lualine.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true} + } + -- colour theme of the $CURRENT_YEAR + use 'rose-pine/neovim' + + -- enable repeating supported plugin maps with '.' + use 'tpope/vim-repeat' + -- pairs of handy bracket mappings + use 'tpope/vim-unimpaired' + -- git wrapper + use { + 'tpope/vim-fugitive', cmd = { 'Git', 'Gstatus', 'Gblame', 'Gpush', 'Gpull' } + } + -- increment dates, times & more + use 'tpope/vim-speeddating' + -- search, substitute and abbreviate + use 'tpope/vim-abolish' + -- provides ga, show unicode stuff of char under cursor + use 'tpope/vim-characterize' + -- comment helper + use 'tpope/vim-commentary' + -- asynchronous build and test dispatcher + use {'tpope/vim-dispatch', opt = true, cmd = {'Dispatch', 'Make', 'Focus', 'Start'}} + + -- fancy start screen + use 'mhinz/vim-startify' +end) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua new file mode 100644 index 0000000..5996c51 --- /dev/null +++ b/.config/nvim/lua/settings.lua @@ -0,0 +1,103 @@ +-- ┌──────────────────┐ +-- │ ▗ │ +-- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ +-- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ +-- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ +-- └──────────────────┘ +-- ┌───────────────────────┐ +-- │ ▐ ▐ ▗ │ +-- │▞▀▘▞▀▖▜▀ ▜▀ ▄ ▛▀▖▞▀▌▞▀▘│ +-- │▝▀▖▛▀ ▐ ▖▐ ▖▐ ▌ ▌▚▄▌▝▀▖│ +-- │▀▀ ▝▀▘ ▀ ▀ ▀▘▘ ▘▗▄▘▀▀ │ +-- └───────────────────────┘ + +local o = vim.o -- gl[o]bal options +local wo = vim.wo -- [w]indow-local [o]ptions +local bo = vim.bo -- [b]uffer-local [o]ptions +local opt = vim.opt -- convenient :set + +-- look & feel +o.termguicolors = true +vim.cmd('colorscheme rose-pine') + +-- interact with system clipboard +opt.clipboard:append('unnamedplus') + +-- copy indent on a new line +o.autoindent = true + +-- :h tabstop, 2. point +-- use appropriate number of spaces to insert a +o.expandtab = true +o.shiftwidth = 4 +o.softtabstop = 4 +o.tabstop = 8 + +-- use english for spellchecking, but don't spellcheck by default +o.spell = true +o.spelllang = "en_gb" +o.spell = false + +-- tab completion, zsh style +o.wildmode = "full" +opt.wildignore = { + '*.o', '*.obj', '*.class', '*.aux', '*.lof', '*.log', '*.lot', '*.fls', + '*.toc', '*.fmt', '*.fot', '*.cb', '*.cb2', '.*.lb', '.dvi', '*.xdv', + '*.bbl', '*.bcf', '*.blg', '*-blx.aux', '*-blx.bib', '*.run.xml', + '*.fdb_latexmk', '*.synctex', '*.synctex(busy)', '*.synctex.gz', + '*.synctex.gz(busy)', '*.pdfsync' +} + +-- put one space while joining (not two) +o.joinspaces = false + +-- keep n lines above/below cursor while scrolling +o.scrolloff = 4 +-- line numbers +o.number = true +-- fold manually, when I place markers +o.foldmethod = "marker" +-- set the terminal title +o.title = true +-- wrap using 'breakat' character +o.linebreak = true +-- new split panes will split to below and right +o.splitbelow = true +o.splitright = true +-- highlight the current line, yoc undoes +o.cursorline = true +-- current line actual number, rest are relative +o.relativenumber = true +-- we are already using a cursorline, don't clobber linter messages +o.showmode = false +-- jump to the matching bracket briefly +o.showmatch = true +-- move freely between buffers +o.hidden = true + +-- persistent undo +o.undodir = "/home/yigit/.vim/undodir" +o.undofile = true + +-- lower case searches ignore case, upper case searches do not +o.ignorecase = true +o.smartcase = true + +-- https://stackoverflow.com/a/3445040/ +-- switch case labels +o.cinoptions = "l1" + +if vim.fn.executable("rg") then + o.grepprg = "rg --vimgrep --no-heading --smart-case" +end + +-- iwhite: ignore changes in amount of white space. +-- vertical: start diff mode with vertical splits +-- filler: show filler lines, +opt.diffopt = { + "iwhite", "vertical", "filler", "algorithm:patience", "indent-heuristic" +} + +-- menu: use a popup menu to show the possible completions +-- preview: show extra information +opt.completeopt = {"menu", "preview"} -- cgit v1.2.3-70-g09d2