From a55162742ca5a417037829ff08f35c71f7dd07a0 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 10 Oct 2021 21:03:02 +0300 Subject: nvim: ported --- .config/nvim/init.lua | 8 +++- .config/nvim/lua/autocmds.lua | 24 ++++++---- .config/nvim/lua/mappings.lua | 31 ++++++++----- .config/nvim/lua/plugin_settings.lua | 87 +++++++++++++++++++++++++++++++++--- .config/nvim/lua/plugins.lua | 12 ++--- .config/nvim/lua/settings.lua | 12 ++--- 6 files changed, 131 insertions(+), 43 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 9dcc9b5..071711d 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -11,8 +11,12 @@ -- │ ▘▝▀▘▝▀▘│ -- └────────┘ +-- do not source the default filetype.vim +-- needed for filetype.nvim +vim.g.did_load_filetypes = 1 + require('plugins') require('settings') -require('autocmds') -require('mappings') require('plugin_settings') +require('mappings') +require('autocmds') diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua index 295dcc2..6b3279e 100644 --- a/.config/nvim/lua/autocmds.lua +++ b/.config/nvim/lua/autocmds.lua @@ -11,13 +11,6 @@ au.TextYankPost = function() vim.highlight.on_yank({ higroup = 'Visual', timeout = 120 }) end -au.BufEnter = { - 'PKGBUILD', - function() - vim.bo.filetype = "PKGBUILD" - end, -} - -- autocmd FileType vimwiki,latex,tex setlocal formatprg=/home/yigit/.local/bin/sentences au.FileType = { 'vimwiki,latex,tex', @@ -54,6 +47,21 @@ au.VimResized = { au.FileType = { 'markdown,text', function() - vim.bo.spell = true + vim.wo.spell = true end, } + +au.BufEnter = { + 'init.lua', + function() + vim.opt.path:append("./lua") + end +} + +au.BufLeave = { + 'init.lua', + function() + vim.opt.path:remove("./lua") + end +} + diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index f27ac1b..6633134 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -1,9 +1,3 @@ --- ┌──────────────────┐ --- │ ▗ │ --- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ --- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ --- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ --- └──────────────────┘ -- ┌────────────────────────┐ -- │ ▗ │ -- │▛▚▀▖▝▀▖▛▀▖▛▀▖▄ ▛▀▖▞▀▌▞▀▘│ @@ -22,6 +16,9 @@ end local cmd = vim.cmd local M = {} +-- edit vimrc \ev +map('n', 'ev', ':tabnew:e ~/.config/nvim/init.lua') + -- brute force deasciify everything map('n', 'tc', 'TurkishDeasciifyForce()', {expr = true}) map('x', 'tc', 'TurkishDeasciifyForce()', {expr = true}) @@ -42,7 +39,7 @@ map('n', 'rtrt', "TurkishAsciify() .. '_'", {expr = true}) map('n', '*', ':keepjumps normal! mi*`i') map('n', '#', ':keepjumps normal! mi#`i ') --- Save file as sudo on files that require root permission +-- 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) @@ -51,25 +48,25 @@ map('n', 'Q', 'gq') -- set formatprg to sentences, for prose map('n', 'fp', ":set formatprg=~/.local/bin/sentences") --- Replace all is aliased to S. +-- 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 +-- 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.. +-- 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 +-- disable highlight when is pressed map('n', '', ':noh') --- Space used to toggle folds, now it's x (because x is d) +-- space used to toggle folds, now it's x (because x is d) map('n', '', '"_x') -- separate cut and delete @@ -106,6 +103,9 @@ local function plugmap(mode, lhs, rhs, opts) vim.api.nvim_set_keymap(mode, lhs, rhs, options) end +-- open the TagBar Plugin +plugmap('n', '', ':TagbarToggle') + -- sneak using grave, s is for sandwich plugmap('n', '`', 'Sneak_s') plugmap('n', '`', 'Sneak_s') @@ -145,4 +145,11 @@ plugmap('n', 'v', 'VimwikiToggleListItem') -- add/increase header level plugmap('n', 'a', 'VimwikiAddHeaderLevel') +-- vim-test bindings +map('n', 't', ':TestNearest') +map('n', 't', ':TestFile') +map('n', 't', ':TestSuite') +map('n', 't', ':TestLast') +map('n', 't', ':TestVisit') + -- 1}}} -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 4e28726..60bbbe1 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -1,9 +1,3 @@ --- ┌──────────────────┐ --- │ ▗ │ --- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ --- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ --- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ --- └──────────────────┘ -- ┌─────────────────────────────────────┐ -- │ ▜ ▐ ▐ ▗ │ -- │▛▀▖▐ ▌ ▌▞▀▌▗▖▖▞▀▘▞▀▖▜▀ ▜▀ ▄ ▛▀▖▞▀▌▞▀▘│ @@ -118,7 +112,86 @@ g.vimtex_view_method = 'zathura' g.vimtex_quickfix_mode = 0 -- }}} vimtex -- -vim.g.polyglot_disabled={'latex', 'tex'} +-- filetype.nvim {{{ -- +require('filetype').setup({ + overrides = { + literal = { + PKGBUILD = 'PKGBUILD', + }, + } +}) +-- }}} filetype.nvim -- + +-- tagbar {{{ -- +g.tagbar_autofocus = 1 +g.tagbar_compact = 1 +g.tagbar_sort = 0 +g.tagbar_width = 25 +-- }}} tagbar -- + +-- ledger {{{ -- +g.ledger_maxwidth = 80 +g.ledger_fillstring = ' -' +-- }}} ledger -- + +-- devicons {{{ -- +require'nvim-web-devicons'.setup { + override = { + wiki = { + icon = "", + color = "#D7827E", + name = "vimwiki" + }, + rem = { + icon = "", + color = "#B4637A", + name = "remind" + } + }; + + default = true +} +-- }}} devicons -- + +-- vim-slime {{{ -- +g.slime_target = "tmux" +g.slime_paste_file = "$HOME/.slime_paste" +g.slime_default_config = {socket_name = vim.call("get", vim.call("split", vim.env.TMUX, ','), "0"), target_pane = "{last}"} +-- }}} vim-slime -- + +-- gutentags {{{ -- +g.gutentags_enabled = 1 +g.gutentags_add_default_project_roots = 0 +g.gutentags_project_root = {'Makefile', '.git'} +g.gutentags_exclude_filetypes = {'gitcommit', 'gitconfig', 'gitrebase', 'gitsendemail', 'git'} +g.gutentags_generate_on_new = 1 +g.gutentags_generate_on_missing = 1 +g.gutentags_generate_on_write = 1 +g.gutentags_generate_on_empty_buffer = 0 +g.gutentags_ctags_exclude = { + '*.git', '*.svn', '*.hg', + 'cache', 'build', 'dist', 'bin', 'node_modules', 'bower_components', + '*-lock.json', '*.lock', + '*.min.*', + '*.bak', + '*.zip', + '*.pyc', + '*.class', + '*.sln', + '*.csproj', '*.csproj.user', + '*.tmp', + '*.cache', + '*.vscode', + '*.pdb', + '*.exe', '*.dll', '*.bin', + '*.mp3', '*.ogg', '*.flac', + '*.swp', '*.swo', + '.DS_Store', '*.plist', + '*.bmp', '*.gif', '*.ico', '*.jpg', '*.png', '*.svg', + '*.rar', '*.zip', '*.tar', '*.tar.gz', '*.tar.xz', '*.tar.bz2', + '*.pdf', '*.doc', '*.docx', '*.ppt', '*.pptx', '*.xls', +} +-- }}} gutentags -- -- float preview g["float_preview#docked"] = 0 diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 4f5420f..8233e44 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -12,7 +12,7 @@ return require('packer').startup(function() -- latex suite use {'lervag/vimtex', ft = {'tex', 'latex', 'plaintext'}} - -- still here + -- still here, going away soon say bye bye use 'dense-analysis/ale' -- manages tag files use 'ludovicchabant/vim-gutentags' @@ -31,13 +31,15 @@ return require('packer').startup(function() use 'ncm2/float-preview.nvim' -- language packs - use 'sheerun/vim-polyglot' - -- i3 config syntax + use "nathom/filetype.nvim" + -- i3 config filetype use 'mboughaba/i3config.vim' -- kitty config filetype use 'fladson/vim-kitty' + -- ledger filetype + use 'ledger/vim-ledger' - use{'junegunn/fzf', dir = '~/.fzf'} + use {'junegunn/fzf', dir = '~/.fzf'} use 'junegunn/fzf.vim' -- file explorer @@ -116,7 +118,7 @@ return require('packer').startup(function() use 'tpope/vim-unimpaired' -- git wrapper use { - 'tpope/vim-fugitive', cmd = { 'Git', 'Gstatus', 'Gblame', 'Gpush', 'Gpull' } + 'tpope/vim-fugitive', cmd = {'Git', 'Gstatus', 'Gblame', 'Gpush', 'Gpull'} } -- increment dates, times & more use 'tpope/vim-speeddating' diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 5996c51..5931e5d 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -1,9 +1,3 @@ --- ┌──────────────────┐ --- │ ▗ │ --- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ --- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ --- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ --- └──────────────────┘ -- ┌───────────────────────┐ -- │ ▐ ▐ ▗ │ -- │▞▀▘▞▀▖▜▀ ▜▀ ▄ ▛▀▖▞▀▌▞▀▘│ @@ -34,9 +28,9 @@ 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 +wo.spell = true +bo.spelllang = "en_gb" +wo.spell = false -- tab completion, zsh style o.wildmode = "full" -- cgit v1.2.3-70-g09d2