From 1fde6ce2467b2ba036fade82f8ba9b71bbffd545 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Thu, 16 Feb 2023 23:40:20 -0800 Subject: nvim: lua config --- nvim/.config/nvim/after/plugin/lsp.lua | 69 +++ nvim/.config/nvim/after/plugin/treesitter.lua | 23 + nvim/.config/nvim/coc-settings.json | 14 - nvim/.config/nvim/colors/jellybeans.vim | 748 -------------------------- nvim/.config/nvim/colors/pencil.vim | 0 nvim/.config/nvim/colors/plain.vim | 85 +-- nvim/.config/nvim/init.lua | 3 + nvim/.config/nvim/init.vim | 281 ---------- nvim/.config/nvim/lua/map.lua | 47 ++ nvim/.config/nvim/lua/plugins.lua | 40 ++ nvim/.config/nvim/lua/set.lua | 55 ++ nvim/.config/nvim/lua/statusline/git.lua | 45 ++ nvim/.config/nvim/lua/statusline/line.lua | 32 ++ nvim/.config/nvim/lua/utils.lua | 18 + nvim/.config/nvim/plugin/packer_compiled.lua | 194 +++++++ 15 files changed, 578 insertions(+), 1076 deletions(-) create mode 100644 nvim/.config/nvim/after/plugin/lsp.lua create mode 100644 nvim/.config/nvim/after/plugin/treesitter.lua delete mode 100755 nvim/.config/nvim/coc-settings.json delete mode 100755 nvim/.config/nvim/colors/jellybeans.vim mode change 100755 => 100644 nvim/.config/nvim/colors/pencil.vim create mode 100644 nvim/.config/nvim/init.lua delete mode 100755 nvim/.config/nvim/init.vim create mode 100644 nvim/.config/nvim/lua/map.lua create mode 100644 nvim/.config/nvim/lua/plugins.lua create mode 100644 nvim/.config/nvim/lua/set.lua create mode 100644 nvim/.config/nvim/lua/statusline/git.lua create mode 100644 nvim/.config/nvim/lua/statusline/line.lua create mode 100644 nvim/.config/nvim/lua/utils.lua create mode 100644 nvim/.config/nvim/plugin/packer_compiled.lua diff --git a/nvim/.config/nvim/after/plugin/lsp.lua b/nvim/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..675c2bd --- /dev/null +++ b/nvim/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,69 @@ +local lsp = require("lsp-zero") + +lsp.preset("recommended") + +lsp.ensure_installed({ + 'rust_analyzer', +}) + +-- Fix Undefined global 'vim' +lsp.configure('sumneko_lua', { + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } +}) + + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), +}) + +-- disable completion with tab +-- this helps with copilot setup +cmp_mappings[''] = nil +cmp_mappings[''] = nil + +lsp.setup_nvim_cmp({ + mapping = cmp_mappings +}) + +lsp.set_preferences({ + suggest_lsp_servers = false, + sign_icons = { + error = 'E', + warn = 'W', + hint = 'H', + info = 'I' + } +}) + +lsp.on_attach(function(client, bufnr) + local opts = {buffer = bufnr, remap = false} + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +lsp.setup() + +vim.diagnostic.config({ + virtual_text = true, +}) + diff --git a/nvim/.config/nvim/after/plugin/treesitter.lua b/nvim/.config/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..9d5d923 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/treesitter.lua @@ -0,0 +1,23 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" + ensure_installed = { "help", "javascript", "typescript", "c", "lua", "rust" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} + diff --git a/nvim/.config/nvim/coc-settings.json b/nvim/.config/nvim/coc-settings.json deleted file mode 100755 index 90df22a..0000000 --- a/nvim/.config/nvim/coc-settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pairs.enableCharacters": ["(", "[", "{", "'", "\"", "`"], - "suggest.noselect": false, - "coc.preferences.formatOnSaveFiletypes": [ - "javascript", - "typescript", - "typescriptreact", - "json", - "javascriptreact", - "typescript.tsx", - "graphql" - ], - "clangd.path": "/home/x/.config/coc/extensions/coc-clangd-data/install/10.0.0/clangd_10.0.0/bin/clangd" -} diff --git a/nvim/.config/nvim/colors/jellybeans.vim b/nvim/.config/nvim/colors/jellybeans.vim deleted file mode 100755 index bae6c69..0000000 --- a/nvim/.config/nvim/colors/jellybeans.vim +++ /dev/null @@ -1,748 +0,0 @@ -" Vim color file -" -" " __ _ _ _ " -" " \ \ ___| | |_ _| |__ ___ __ _ _ __ ___ " -" " \ \/ _ \ | | | | | _ \ / _ \/ _ | _ \/ __| " -" " /\_/ / __/ | | |_| | |_| | __/ |_| | | | \__ \ " -" " \___/ \___|_|_|\__ |____/ \___|\____|_| |_|___/ " -" " \___/ " -" -" "A colorful, dark color scheme for Vim." -" -" File: jellybeans.vim -" URL: github.com/nanotech/jellybeans.vim -" Scripts URL: vim.org/scripts/script.php?script_id=2555 -" Maintainer: NanoTech (nanotech.nanotechcorp.net) -" Version: 1.7 -" Last Change: June 21st, 2019 -" License: MIT -" Contributors: Andrew Wong (w0ng) -" Benjamin R. Haskell (benizi) -" Brian Marshall (bmars) -" Daniel Herbert (pocketninja) -" David Liang -" Filipe Silva (ninrod) -" Henry So, Jr. -" Ihor Kalnytskyi (ikalnytskyi) -" Joe Doherty (docapotamus) -" Karl Litterfeldt (Litterfeldt) -" Keith Pitt (keithpitt) -" Mike Schreifels (schreifels) -" Philipp Rustemeier (12foo) -" Rafael Bicalho (rbika) -" Rich Healey (richo) -" Siwen Yu (yusiwen) -" Tim Willis (willist) -" Tom McLaughlin (tmcoma) -" -" Copyright (c) 2009-2019 NanoTech -" -" Permission is hereby granted, free of charge, to any per‐ -" son obtaining a copy of this software and associated doc‐ -" umentation files (the “Software”), to deal in the Soft‐ -" ware without restriction, including without limitation -" the rights to use, copy, modify, merge, publish, distrib‐ -" ute, sublicense, and/or sell copies of the Software, and -" to permit persons to whom the Software is furnished to do -" so, subject to the following conditions: -" -" The above copyright notice and this permission notice -" shall be included in all copies or substantial portions -" of the Software. -" -" THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY -" KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -" THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICU‐ -" LAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CON‐ -" TRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON‐ -" NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -" THE SOFTWARE. - -set background=dark - -hi clear - -if exists("syntax_on") - syntax reset -endif - -let colors_name = "jellybeans" - -if has("gui_running") || (has('termguicolors') && &termguicolors) - let s:true_color = 1 -else - let s:true_color = 0 -endif - -if s:true_color || &t_Co >= 88 - let s:low_color = 0 -else - let s:low_color = 1 -endif - -" Configuration Variables: -" - g:jellybeans_overrides (default = {}) -" - g:jellybeans_use_lowcolor_black (default = 0) -" - g:jellybeans_use_gui_italics (default = 1) -" - g:jellybeans_use_term_italics (default = 0) - -let s:background_color = "NONE" -let s:background_color = "000000" - -if exists("g:jellybeans_overrides") - let s:overrides = g:jellybeans_overrides -else - let s:overrides = {} -endif - -" Backwards compatibility -if exists("g:jellybeans_background_color") - \ || exists("g:jellybeans_background_color_256") - \ || exists("g:jellybeans_use_term_background_color") - - let s:overrides = deepcopy(s:overrides) - - if !has_key(s:overrides, "background") - let s:overrides["background"] = {} - endif - - if exists("g:jellybeans_background_color") - let s:overrides["background"]["guibg"] = g:jellybeans_background_color - endif - - if exists("g:jellybeans_background_color_256") - let s:overrides["background"]["256ctermbg"] = g:jellybeans_background_color_256 - endif - - if exists("g:jellybeans_use_term_background_color") - \ && g:jellybeans_use_term_background_color - let s:overrides["background"]["ctermbg"] = "NONE" - let s:overrides["background"]["256ctermbg"] = "NONE" - endif -endif - -if exists("g:jellybeans_use_lowcolor_black") && g:jellybeans_use_lowcolor_black - let s:termBlack = "Black" -else - let s:termBlack = "Grey" -endif - -" When `termguicolors` is set, Vim[^1] ignores `hi Normal guibg=NONE` -" after Normal's `guibg` is already set to a color. See: -" -" - https://github.com/vim/vim/issues/981 -" - https://github.com/nanotech/jellybeans.vim/issues/64 -" -" To work around this, ensure we don't set the default background -" color before an override changes it to `NONE` by ensuring that the -" background color isn't set to a value different from its override. -" -" [^1]: Tested on 8.0.567. Does not apply to Neovim. -" -if has_key(s:overrides, "background") && has_key(s:overrides["background"], "guibg") - let s:background_color = s:overrides["background"]["guibg"] -endif - -" Color approximation functions by Henry So, Jr. and David Liang {{{ -" Added to jellybeans.vim by Daniel Herbert - -if &t_Co == 88 - - " returns an approximate grey index for the given grey level - fun! s:grey_number(x) - if a:x < 23 - return 0 - elseif a:x < 69 - return 1 - elseif a:x < 103 - return 2 - elseif a:x < 127 - return 3 - elseif a:x < 150 - return 4 - elseif a:x < 173 - return 5 - elseif a:x < 196 - return 6 - elseif a:x < 219 - return 7 - elseif a:x < 243 - return 8 - else - return 9 - endif - endfun - - " returns the actual grey level represented by the grey index - fun! s:grey_level(n) - if a:n == 0 - return 0 - elseif a:n == 1 - return 46 - elseif a:n == 2 - return 92 - elseif a:n == 3 - return 115 - elseif a:n == 4 - return 139 - elseif a:n == 5 - return 162 - elseif a:n == 6 - return 185 - elseif a:n == 7 - return 208 - elseif a:n == 8 - return 231 - else - return 255 - endif - endfun - - " returns the palette index for the given grey index - fun! s:grey_color(n) - if a:n == 0 - return 16 - elseif a:n == 9 - return 79 - else - return 79 + a:n - endif - endfun - - " returns an approximate color index for the given color level - fun! s:rgb_number(x) - if a:x < 69 - return 0 - elseif a:x < 172 - return 1 - elseif a:x < 230 - return 2 - else - return 3 - endif - endfun - - " returns the actual color level for the given color index - fun! s:rgb_level(n) - if a:n == 0 - return 0 - elseif a:n == 1 - return 139 - elseif a:n == 2 - return 205 - else - return 255 - endif - endfun - - " returns the palette index for the given R/G/B color indices - fun! s:rgb_color(x, y, z) - return 16 + (a:x * 16) + (a:y * 4) + a:z - endfun - -else " assuming &t_Co == 256 - - " returns an approximate grey index for the given grey level - fun! s:grey_number(x) - if a:x < 14 - return 0 - else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n - else - return l:n + 1 - endif - endif - endfun - - " returns the actual grey level represented by the grey index - fun! s:grey_level(n) - if a:n == 0 - return 0 - else - return 8 + (a:n * 10) - endif - endfun - - " returns the palette index for the given grey index - fun! s:grey_color(n) - if a:n == 0 - return 16 - elseif a:n == 25 - return 231 - else - return 231 + a:n - endif - endfun - - " returns an approximate color index for the given color level - fun! s:rgb_number(x) - if a:x < 75 - return 0 - else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n - else - return l:n + 1 - endif - endif - endfun - - " returns the actual color level for the given color index - fun! s:rgb_level(n) - if a:n == 0 - return 0 - else - return 55 + (a:n * 40) - endif - endfun - - " returns the palette index for the given R/G/B color indices - fun! s:rgb_color(x, y, z) - return 16 + (a:x * 36) + (a:y * 6) + a:z - endfun - -endif - -" returns the palette index to approximate the given R/G/B color levels -fun! s:color(r, g, b) - " map greys directly (see xterm's 256colres.pl) - if &t_Co == 256 && a:r == a:g && a:g == a:b && a:r > 3 && a:r < 243 - return (a:r - 8) / 10 + 232 - endif - - " get the closest grey - let l:gx = s:grey_number(a:r) - let l:gy = s:grey_number(a:g) - let l:gz = s:grey_number(a:b) - - " get the closest color - let l:x = s:rgb_number(a:r) - let l:y = s:rgb_number(a:g) - let l:z = s:rgb_number(a:b) - - if l:gx == l:gy && l:gy == l:gz - " there are two possibilities - let l:dgr = s:grey_level(l:gx) - a:r - let l:dgg = s:grey_level(l:gy) - a:g - let l:dgb = s:grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = s:rgb_level(l:gx) - a:r - let l:dg = s:rgb_level(l:gy) - a:g - let l:db = s:rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb - " use the grey - return s:grey_color(l:gx) - else - " use the color - return s:rgb_color(l:x, l:y, l:z) - endif - else - " only one possibility - return s:rgb_color(l:x, l:y, l:z) - endif -endfun - -fun! s:is_empty_or_none(str) - return empty(a:str) || a:str ==? "NONE" -endfun - -" returns the palette index to approximate the 'rrggbb' hex string -fun! s:rgb(rgb) - if s:is_empty_or_none(a:rgb) - return "NONE" - endif - let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 - return s:color(l:r, l:g, l:b) -endfun - -fun! s:prefix_highlight_value_with(prefix, color) - if s:is_empty_or_none(a:color) - return "NONE" - else - return a:prefix . a:color - endif -endfun - -fun! s:remove_italic_attr(attr) - let l:attr = join(filter(split(a:attr, ","), "v:val !=? 'italic'"), ",") - if empty(l:attr) - let l:attr = "NONE" - endif - return l:attr -endfun - -" sets the highlighting for the given group -fun! s:X(group, fg, bg, attr, lcfg, lcbg) - if s:low_color - let l:cmd = "hi ".a:group. - \ " ctermfg=".s:prefix_highlight_value_with("", a:lcfg). - \ " ctermbg=".s:prefix_highlight_value_with("", a:lcbg) - else - let l:cmd = "hi ".a:group. - \ " guifg=".s:prefix_highlight_value_with("#", a:fg). - \ " guibg=".s:prefix_highlight_value_with("#", a:bg) - if !s:true_color - let l:cmd = l:cmd. - \ " ctermfg=".s:rgb(a:fg). - \ " ctermbg=".s:rgb(a:bg) - endif - endif - - let l:attr = s:prefix_highlight_value_with("", a:attr) - - if exists("g:jellybeans_use_term_italics") && g:jellybeans_use_term_italics - let l:cterm_attr = l:attr - else - let l:cterm_attr = s:remove_italic_attr(l:attr) - endif - - if !exists("g:jellybeans_use_gui_italics") || g:jellybeans_use_gui_italics - let l:gui_attr = l:attr - else - let l:gui_attr = s:remove_italic_attr(l:attr) - endif - - let l:cmd = l:cmd." gui=".l:gui_attr." cterm=".l:cterm_attr - exec l:cmd -endfun -" }}} - -call s:X("Normal","e8e8d3",s:background_color,"","White","") -set background=dark - -call s:X("CursorLine","","1c1c1c","","",s:termBlack) -call s:X("CursorColumn","","1c1c1c","","",s:termBlack) - -" Some of Terminal.app's default themes have a cursor color -" too close to Jellybeans' preferred MatchParen background -" color to be easily distinguishable. Other terminals tend -" to use a brighter cursor color. -" -" Use a more distinct color in Terminal.app, and also in -" low-color terminals if the preferred background color is -" not available. -if !has('gui_running') && $TERM_PROGRAM == "Apple_Terminal" - let s:matchParenGuiFg = "dd0093" - let s:matchParenGuiBg = "000000" -else - let s:matchParenGuiFg = "ffffff" - let s:matchParenGuiBg = "556779" -endif -if s:termBlack != "Black" - let s:matchParenTermFg = "Magenta" - let s:matchParenTermBg = "" -else - let s:matchParenTermFg = "" - let s:matchParenTermBg = s:termBlack -endif -call s:X("MatchParen",s:matchParenGuiFg,s:matchParenGuiBg,"bold", -\ s:matchParenTermFg,s:matchParenTermBg) - -call s:X("TabLine","000000","b0b8c0","italic","",s:termBlack) -call s:X("TabLineFill","9098a0","","","",s:termBlack) -call s:X("TabLineSel","000000","f0f0f0","italic,bold",s:termBlack,"White") - -" Auto-completion -call s:X("Pmenu","ffffff","606060","","White",s:termBlack) -call s:X("PmenuSel","101010","eeeeee","",s:termBlack,"White") - -call s:X("Visual","","404040","","",s:termBlack) -call s:X("Cursor",s:background_color,"b0d0f0","","","") - -call s:X("LineNr","605958",s:background_color,"NONE",s:termBlack,"") -call s:X("CursorLineNr","ccc5c4","","NONE","White","") -call s:X("Comment","888888","","italic","Grey","") -call s:X("Todo","c7c7c7","","bold","White",s:termBlack) - -call s:X("StatusLine","000000","dddddd","italic","","White") -call s:X("StatusLineNC","ffffff","403c41","italic","White","Black") -call s:X("VertSplit","282828","403c41","",s:termBlack,s:termBlack) -call s:X("WildMenu","f0a0c0","302028","","Magenta","") - -call s:X("Folded","a0a8b0","384048","italic",s:termBlack,"") -call s:X("FoldColumn","535D66","1f1f1f","","",s:termBlack) -call s:X("SignColumn","777777","333333","","",s:termBlack) -call s:X("ColorColumn","","000000","","",s:termBlack) - -call s:X("Title","70b950","","bold","Green","") - -call s:X("Constant","cf6a4c","","","Red","") -call s:X("Special","799d6a","","","Green","") -call s:X("Delimiter","668799","","","Grey","") - -call s:X("String","99ad6a","","","Green","") -call s:X("StringDelimiter","556633","","","DarkGreen","") - -call s:X("Identifier","c6b6ee","","","LightCyan","") -call s:X("Structure","8fbfdc","","","LightCyan","") -call s:X("Function","fad07a","","","Yellow","") -call s:X("Statement","8197bf","","","DarkBlue","") -call s:X("PreProc","8fbfdc","","","LightBlue","") - -hi! link Operator Structure -hi! link Conceal Operator - -call s:X("Type","ffb964","","","Yellow","") -call s:X("NonText","606060",s:background_color,"",s:termBlack,"") - -call s:X("SpecialKey","444444","1c1c1c","",s:termBlack,"") - -call s:X("Search","f0a0c0","302028","underline","Magenta","") - -call s:X("Directory","dad085","","","Yellow","") -call s:X("ErrorMsg","","a03949","","","DarkRed") -hi! link Error ErrorMsg -hi! link MoreMsg Special -call s:X("Question","65C254","","","Green","") - - -" Spell Checking - -call s:X("SpellBad","","902020","underline","","DarkRed") -call s:X("SpellCap","","0000df","underline","","Blue") -call s:X("SpellRare","","540063","underline","","DarkMagenta") -call s:X("SpellLocal","","2D7067","underline","","Green") - -" Diff - -hi! link diffRemoved Constant -hi! link diffAdded String - -" VimDiff - -call s:X("DiffAdd","D2EBBE","437019","","White","DarkGreen") -call s:X("DiffDelete","40000A","700009","","DarkRed","DarkRed") -call s:X("DiffChange","","2B5B77","","White","DarkBlue") -call s:X("DiffText","8fbfdc","000000","reverse","Yellow","") - -" PHP - -hi! link phpFunctions Function -call s:X("StorageClass","c59f6f","","","Red","") -hi! link phpSuperglobal Identifier -hi! link phpQuoteSingle StringDelimiter -hi! link phpQuoteDouble StringDelimiter -hi! link phpBoolean Constant -hi! link phpNull Constant -hi! link phpArrayPair Operator -hi! link phpOperator Normal -hi! link phpRelation Normal -hi! link phpVarSelector Identifier - -" Python - -hi! link pythonOperator Statement - -" Ruby - -hi! link rubySharpBang Comment -call s:X("rubyClass","447799","","","DarkBlue","") -call s:X("rubyIdentifier","c6b6fe","","","Cyan","") -hi! link rubyConstant Type -hi! link rubyFunction Function - -call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","") -call s:X("rubySymbol","7697d6","","","Blue","") -hi! link rubyGlobalVariable rubyInstanceVariable -hi! link rubyModule rubyClass -call s:X("rubyControl","7597c6","","","Blue","") - -hi! link rubyString String -hi! link rubyStringDelimiter StringDelimiter -hi! link rubyInterpolationDelimiter Identifier - -call s:X("rubyRegexpDelimiter","540063","","","Magenta","") -call s:X("rubyRegexp","dd0093","","","DarkMagenta","") -call s:X("rubyRegexpSpecial","a40073","","","Magenta","") - -call s:X("rubyPredefinedIdentifier","de5577","","","Red","") - -" Erlang - -hi! link erlangAtom rubySymbol -hi! link erlangBIF rubyPredefinedIdentifier -hi! link erlangFunction rubyPredefinedIdentifier -hi! link erlangDirective Statement -hi! link erlangNode Identifier - -" Elixir - -hi! link elixirAtom rubySymbol - - -" JavaScript - -hi! link javaScriptValue Constant -hi! link javaScriptRegexpString rubyRegexp -hi! link javaScriptTemplateVar StringDelim -hi! link javaScriptTemplateDelim Identifier -hi! link javaScriptTemplateString String - -" CoffeeScript - -hi! link coffeeRegExp javaScriptRegexpString - -" Lua - -hi! link luaOperator Conditional - -" C - -hi! link cFormat Identifier -hi! link cOperator Constant - -" Objective-C/Cocoa - -hi! link objcClass Type -hi! link cocoaClass objcClass -hi! link objcSubclass objcClass -hi! link objcSuperclass objcClass -hi! link objcDirective rubyClass -hi! link objcStatement Constant -hi! link cocoaFunction Function -hi! link objcMethodName Identifier -hi! link objcMethodArg Normal -hi! link objcMessageName Identifier - -" Vimscript - -hi! link vimOper Normal - -" HTML - -hi! link htmlTag Statement -hi! link htmlEndTag htmlTag -hi! link htmlTagName htmlTag - -" XML - -hi! link xmlTag Statement -hi! link xmlEndTag xmlTag -hi! link xmlTagName xmlTag -hi! link xmlEqual xmlTag -hi! link xmlEntity Special -hi! link xmlEntityPunct xmlEntity -hi! link xmlDocTypeDecl PreProc -hi! link xmlDocTypeKeyword PreProc -hi! link xmlProcessingDelim xmlAttrib - -" Debugger.vim - -call s:X("DbgCurrent","DEEBFE","345FA8","","White","DarkBlue") -call s:X("DbgBreakPt","","4F0037","","","DarkMagenta") - -" vim-indent-guides - -if !exists("g:indent_guides_auto_colors") - let g:indent_guides_auto_colors = 0 -endif -call s:X("IndentGuidesOdd","","232323","","","") -call s:X("IndentGuidesEven","","1b1b1b","","","") - -" Plugins, etc. - -hi! link TagListFileName Directory -call s:X("PreciseJumpTarget","B9ED67","405026","","White","Green") - -" Manual overrides for 256-color terminals. Dark colors auto-map badly. -if !s:low_color - hi StatusLineNC ctermbg=235 - hi Folded ctermbg=236 - hi DiffText ctermfg=81 - hi DbgBreakPt ctermbg=53 - hi IndentGuidesOdd ctermbg=235 - hi IndentGuidesEven ctermbg=234 -endif - -if !empty("s:overrides") - fun! s:current_attr(group) - let l:synid = synIDtrans(hlID(a:group)) - let l:attrs = [] - for l:attr in ["bold", "italic", "reverse", "standout", "underline", "undercurl"] - if synIDattr(l:synid, l:attr, "gui") == 1 - call add(l:attrs, l:attr) - endif - endfor - return join(l:attrs, ",") - endfun - fun! s:current_color(group, what, mode) - let l:color = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode) - if l:color == -1 - return "" - else - return substitute(l:color, "^#", "", "") - endif - endfun - fun! s:load_color_def(group, def) - call s:X(a:group, get(a:def, "guifg", s:current_color(a:group, "fg", "gui")), - \ get(a:def, "guibg", s:current_color(a:group, "bg", "gui")), - \ get(a:def, "attr", s:current_attr(a:group)), - \ get(a:def, "ctermfg", s:current_color(a:group, "fg", "cterm")), - \ get(a:def, "ctermbg", s:current_color(a:group, "bg", "cterm"))) - if !s:low_color - for l:prop in ["ctermfg", "ctermbg"] - let l:override_key = "256".l:prop - if has_key(a:def, l:override_key) - exec "hi ".a:group." ".l:prop."=".a:def[l:override_key] - endif - endfor - endif - endfun - fun! s:load_colors(defs) - for [l:group, l:def] in items(a:defs) - if l:group == "background" - call s:load_color_def("LineNr", l:def) - call s:load_color_def("NonText", l:def) - call s:load_color_def("Normal", l:def) - else - call s:load_color_def(l:group, l:def) - endif - unlet l:group - unlet l:def - endfor - endfun - call s:load_colors(s:overrides) - delf s:load_colors - delf s:load_color_def - delf s:current_color - delf s:current_attr -endif - -" delete functions {{{ -delf s:X -delf s:remove_italic_attr -delf s:prefix_highlight_value_with -delf s:rgb -delf s:is_empty_or_none -delf s:color -delf s:rgb_color -delf s:rgb_level -delf s:rgb_number -delf s:grey_color -delf s:grey_level -delf s:grey_number -" }}} - -" extras -hi NERDTreeHelp guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpKey guifg=#c9d05c ctermfg=185 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpCommand guifg=#ffc24b ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpTitle guifg=#b3deef ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeUp guifg=#c9d05c ctermfg=185 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeCWD guifg=#73cef4 ctermfg=81 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeOpenable guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeClosable guifg=#ffc24b ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterAdd guifg=#c9d05c ctermfg=185 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterChange guifg=#b3deef ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterDelete guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterChangeDelete guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE diff --git a/nvim/.config/nvim/colors/pencil.vim b/nvim/.config/nvim/colors/pencil.vim old mode 100755 new mode 100644 diff --git a/nvim/.config/nvim/colors/plain.vim b/nvim/.config/nvim/colors/plain.vim index 4b712bd..80f0b0e 100644 --- a/nvim/.config/nvim/colors/plain.vim +++ b/nvim/.config/nvim/colors/plain.vim @@ -1,3 +1,17 @@ +" Name: plain.vim +" Version: 0.1 +" Maintainer: github.com/andreypopp +" License: The MIT License (MIT) +" +" Based on +" +" https://github.com/pbrisbin/vim-colors-off (MIT License) +" +" which in turn based on +" +" https://github.com/reedes/vim-colors-pencil (MIT License) +" +""" hi clear if exists('syntax on') @@ -10,8 +24,8 @@ let s:black = { "gui": "#222222", "cterm": "0" } let s:medium_gray = { "gui": "#767676", "cterm": "8" } let s:white = { "gui": "#F1F1F1", "cterm": "7" } let s:actual_white = { "gui": "#FFFFFF", "cterm": "15" } -let s:light_black = { "gui": "#424242", "cterm": "11" } -let s:lighter_black = { "gui": "#545454", "cterm": "12" } +let s:light_black = { "gui": "#424242", "cterm": "8" } +let s:lighter_black = { "gui": "#545454", "cterm": "8" } let s:subtle_black = { "gui": "#303030", "cterm": "11" } let s:light_gray = { "gui": "#999999", "cterm": "12" } let s:lighter_gray = { "gui": "#CCCCCC", "cterm": "7" } @@ -34,25 +48,6 @@ let s:light_yellow = { "gui": "#F3E430", "cterm": "3" } let s:dark_yellow = { "gui": "#A89C14", "cterm": "3" } if &background == "dark" - let s:bg = s:white - let s:bg_subtle = s:lighter_gray - let s:bg_very_subtle = s:light_gray - let s:norm = s:light_black - let s:norm_subtle = s:lighter_black - let s:purple = s:dark_purple - let s:cyan = s:dark_cyan - let s:green = s:dark_green - let s:red = s:dark_red - let s:yellow = s:dark_yellow - let s:visual = s:light_blue - let s:cursor_line = s:medium_gray - let s:status_line = s:lighter_gray - let s:status_line_nc = s:lighter_black - let s:constant = s:dark_blue - let s:comment = s:light_gray - let s:selection = s:light_yellow - let s:warning = s:yellow -else let s:bg = s:black let s:bg_subtle = s:light_black let s:bg_very_subtle = s:subtle_black @@ -71,6 +66,25 @@ else let s:comment = s:lighter_black let s:selection = s:light_purple let s:warning = s:yellow +else + let s:bg = s:white + let s:bg_subtle = s:lighter_gray + let s:bg_very_subtle = s:light_gray + let s:norm = s:light_black + let s:norm_subtle = s:lighter_black + let s:purple = s:dark_purple + let s:cyan = s:dark_cyan + let s:green = s:dark_green + let s:red = s:dark_red + let s:yellow = s:dark_yellow + let s:visual = s:light_blue + let s:cursor_line = s:medium_gray + let s:status_line = s:lighter_gray + let s:status_line_nc = s:lighter_black + let s:constant = s:dark_blue + let s:comment = s:light_gray + let s:selection = s:light_yellow + let s:warning = s:yellow endif " https://github.com/noahfrederick/vim-hemisu/ @@ -93,7 +107,6 @@ call s:h("Noise", {"fg": s:norm_subtle}) call s:h("Cursor", {"bg": s:green, "fg": s:norm}) call s:h("Comment", {"fg": s:comment, "cterm": "italic"}) call s:h("Function", {"fg": s:norm, "cterm": "bold"}) -call s:h("FloatWin", {"fg": s:norm, "bg": s:black}) hi! link Constant firstAccent hi! link Character Constant @@ -193,7 +206,7 @@ call s:h("StatusLineOk", {"gui": "underline", "bg": s:bg, "fg": s:green}) call s:h("StatusLineError", {"gui": "underline", "bg": s:bg, "fg": s:pink}) call s:h("StatusLineWarning", {"gui": "underline", "bg": s:bg, "fg": s:warning}) -call s:h("Pmenu", {"fg": s:norm, "bg": s:bg_subtle}) +call s:h("Pmenu", {"fg": s:norm, "bg": s:bg_very_subtle}) call s:h("PmenuSel", {"fg": s:green, "bg": s:bg_very_subtle, "gui": "bold"}) call s:h("PmenuSbar", {"fg": s:norm, "bg": s:bg_subtle}) call s:h("PmenuThumb", {"fg": s:norm, "bg": s:bg_subtle}) @@ -239,7 +252,7 @@ hi link TSBoolean Constant hi link TSCharacter Constant hi link TSComment Comment hi link TSConstructor Normal -hi link TSConditional Statement +hi link TSConditional Normal hi link TSConstant Constant hi link TSConstBuiltin secondAccent hi link TSConstMacro secondAccent @@ -248,18 +261,18 @@ hi link TSException Error hi link TSField Normal hi link TSFloat Constant hi link TSFunction Normal -hi link TSFuncBuiltin secondAccent +hi link TSFuncBuiltin Noise hi link TSFuncMacro secondAccent hi link TSInclude Noise -hi link TSKeyword Statement -hi link TSKeywordFunction Statement +hi link TSKeyword Noise +hi link TSKeywordFunction Noise hi link TSLabel Noise hi link TSMethod Normal hi link TSNamespace Noise hi link TSNone Noise hi link TSNumber Constant hi link TSOperator Normal -hi link TSParameter Noise +hi link TSParameter Statement hi link TSParameterReference Statement hi link TSProperty TSField hi link TSPunctDelimiter Noise @@ -269,6 +282,7 @@ hi link TSRepeat Normal hi link TSString Constant hi link TSStringRegex secondAccent hi link TSStringEscape secondAccent +hi link TSStringSpecial secondAccent hi link TSTag Statement hi link TSTagDelimiter Noise hi link TSText Normal @@ -278,11 +292,10 @@ hi link TSStrike Underlined hi link TSTitle Statement hi link TSLiteral Noise hi link TSURI Constant -hi link TSType Noise +hi link TSType secondAccent hi link TSTypeBuiltin secondAccent hi link TSVariable Normal hi link TSVariableBuiltin Normal -hi link TSRepeat Statement " nvim-lsp diagnostics hi link LspDiagnosticsDefaultError Error @@ -332,6 +345,15 @@ hi link cFormat secondAccent hi link nixBuiltin secondAccent hi link nixNamespacedBuiltin secondAccent +hi link awkPatterns secondAccent +hi link awkVariables Normal +hi link awkOperator Normal +hi link awkExpression Noise +hi link awkArrayElement Noise +hi link awkFieldVars firstAccent +hi link awkSpecialPrintf secondAccent +hi link awkSpecialCharacter Noise + hi link sqlSpecial firstAccent hi link sqlKeyword secondAccent @@ -364,6 +386,3 @@ hi link markdownHeadingDelimiter Constant call s:h("cssBraces", {"bg": s:bg, "fg": s:selection}) hi link cssTextProp Noise hi link cssTagName Normal - -" floatwin -hi link NormalFloat FloatWin diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..af18fe3 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,3 @@ +require("map") +require("set") +require("plugins") diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100755 index 31f8aa2..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,281 +0,0 @@ -" vimplug -call plug#begin() -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' -Plug 'Shougo/deol.nvim' -Plug 'ap/vim-css-color' -Plug 'tpope/vim-eunuch' -Plug 'tpope/vim-commentary' -Plug 'scrooloose/nerdtree' -Plug 'junegunn/goyo.vim' -Plug 'airblade/vim-gitgutter' -Plug 'godlygeek/tabular' -Plug 'plasticboy/vim-markdown' -Plug 'sh-ubh/vim-bujo' -Plug 'lervag/vimtex' -Plug 'metakirby5/codi.vim' -Plug 'hashivim/vim-terraform' -call plug#end() - -" sets -set guicursor= -set number relativenumber -set mouse=a -set background=dark -syntax enable -set cursorline -set ignorecase -set smartcase -set wildmenu " Tab autocomplete in command mode -set autoread " Auto reload changed files - -" Spaces & Tabs -set tabstop=4 " number of visual spaces per TAB -set softtabstop=4 " number of spaces in tab when editing -set shiftwidth=4 " number of spaces to use for autoindent -set expandtab " tabs are space -set autoindent -set copyindent " copy indent from the previous line -colorscheme pencil -"hi Normal ctermbg=16 guibg=#000000 -"hi LineNr ctermbg=16 guibg=#000000 - -" Change background based on macos theme -" let output = system("defaults read -g AppleInterfaceStyle") -" if v:shell_error != 0 -" set background=light -" colorscheme plain -" else -" set background=dark -" colorscheme pencil -" endif - -let mapleader=" " - -" Reload vimrc -nnoremap sv :source $VIMRC - -" Alias write and quit to Q -nnoremap q :wq -nnoremap w :w - -" toggle fzf -nnoremap :FZF - -" Save file as sudo when no sudo permissions -cmap w!! w !sudo tee > /dev/null % - -" vim-bujo -nmap BujoAddnormal -imap BujoAddinsert -nmap BujoChecknormal -imap BujoCheckinsert - -" nerdtree -let g:NERDTreeWinPos = "right" -map n :NERDTreeToggle -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif - -" system clipboard -" set clipboard+=unnamedplus - -" Fix indenting visual block -vmap < >gv - -" git gutter settings -highlight GitGutterAdd guifg=#009900 ctermfg=Green -highlight GitGutterChange guifg=#bbbb00 ctermfg=Yellow -highlight GitGutterDelete guifg=#ff2222 ctermfg=Red -nmap ) (GitGutterNextHunk) -nmap ( (GitGutterPrevHunk) -let g:gitgutter_enabled = 1 -let g:gitgutter_map_keys = 0 -let g:gitgutter_highlight_linenrs = 1 - -" vim-markdown -let g:vim_markdown_no_default_key_mappings=1 -let g:vim_markdown_toml_frontmatter=1 -let g:vim_markdown_yaml_frontmatter=1 -let g:vim_markdown_folding_disabled=1 -let g:vim_markdown_conceal=0 - -" vimtex -let g:tex_flavor = 'latex' - -" insert centered -autocmd InsertEnter * norm zz - -" shortcut split navigation -map h -map j -map k -map l - -" replace all using S -nnoremap S :%s//gI - -" italic comments -hi Comment cterm=italic - -" statusbar -scriptencoding utf-8 - -" templates -autocmd BufNewFile * silent! 0r $HOME/.config/nvim/templates/skelton.%:e - -" statusline -hi PrimaryBlock ctermbg=NONE ctermfg=237 -hi ModeBlock ctermbg=NONE ctermfg=2 -hi SecondaryBlock ctermbg=NONE ctermfg=237 -hi TeritaryBlock ctermbg=NONE ctermfg=9 -hi Blanks ctermbg=NONE -hi statusline ctermbg=NONE -let g:currentmode={ - \ 'n' : 'NORMAL ', - \ 'no' : 'N·OPERATOR PENDING ', - \ 'v' : 'VISUAL ', - \ 'V' : 'V·LINE ', - \ '' : 'V·BLOCK ', - \ 's' : 'SELECT ', - \ 'S' : 'S·LINE ', - \ '' : 'S·BLOCK ', - \ 'i' : 'INSERT ', - \ 'R' : 'REPLACE ', - \ 'Rv' : 'V·REPLACE ', - \ 'c' : 'COMMAND ', - \ 'cv' : 'VIM EX ', - \ 'ce' : 'EX ', - \ 'r' : 'PROMPT ', - \ 'rm' : 'MORE ', - \ 'r?' : 'CONFIRM ', - \ '!' : 'SHELL ', - \ 't' : 'TERMINAL '} -set statusline= -set statusline+=%#ModeBlock# -set statusline+=\ %{g:currentmode[mode()]} -set statusline+=%#TeritaryBlock# -set statusline+=\ %f\ -set statusline+=%M\ -set statusline+=%#Blanks# -set statusline+=%= -set statusline+=%#PrimaryBlock# -set statusline+=\ %Y\ -set statusline+=%#SecondaryBlock# -set statusline+=\ %P\ - -" ------COC SETTINGS------ -" prettier command for coc -command! -nargs=0 Prettier :CocCommand prettier.formatFile -let g:coc_global_extensions = [ - \ 'coc-snippets', - \ 'coc-pairs', - \ 'coc-prettier', - \ 'coc-tsserver', - \ 'coc-html', - \ 'coc-css', - \ 'coc-json', - \ 'coc-clangd', - \ 'coc-python', - \ 'coc-sh', - \ 'coc-vimtex', - \ 'coc-go' - \ ] - -" From Coc Readme -set updatetime=300 - -" Some servers have issues with backup files, see #649 -set nobackup -set nowritebackup - -" don't give |ins-completion-menu| messages. -set shortmess+=c - -" always show signcolumns -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate. -" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. -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 - -" Use to trigger completion. -inoremap coc#refresh() - -" Use to confirm completion, `u` means break undo chain at current position. -" Coc only does snippet and additional edit on confirm. -inoremap pumvisible() ? "\" : "\u\" -" Or use `complete_info` if your vim support it, like: -" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - -" Use `[g` and `]g` to navigate diagnostics -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" Remap keys for gotos -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction - -" Remap for rename current word -nmap (coc-rename) - -" Remap for format selected region -xmap f (coc-format-selected) -nmap f (coc-format-selected) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Remap for do codeAction of selected region, ex: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap for do codeAction of current line -nmap ac (coc-codeaction) -" Fix autofix problem of current line -nmap qf (coc-fix-current) - -" Create mappings for function text object, requires document symbols feature of languageserver. -xmap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap if (coc-funcobj-i) -omap af (coc-funcobj-a) - -" Use `:Format` to format current buffer -command! -nargs=0 Format :call CocAction('format') - -" Use `:Fold` to fold current buffer -command! -nargs=? Fold :call CocAction('fold', ) - -" use `:OR` for organize import of current buffer -command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - -" Add status line support, for integration with other plugin, checkout `:h coc-status` -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} diff --git a/nvim/.config/nvim/lua/map.lua b/nvim/.config/nvim/lua/map.lua new file mode 100644 index 0000000..b158332 --- /dev/null +++ b/nvim/.config/nvim/lua/map.lua @@ -0,0 +1,47 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "n", vim.cmd.Ex) + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({"n", "v"}, "d", [["_d]]) + +vim.keymap.set("n", "f", vim.lsp.buf.format) + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") + +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) + +vim.keymap.set("n", "", ":FZF") +vim.keymap.set("n", "q", ":wq") +vim.keymap.set("n", "w", ":w") + +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") + +vim.keymap.set("n", "S", ":%s//gI") + +-- bujo +vim.keymap.set("n", "", "BujoAddnormal") +vim.keymap.set("i", "", "BujoAddinsert") +vim.keymap.set("n", "", "BujoChecknormal") +vim.keymap.set("i", "", "BujoCheckinsert") diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..569a7fc --- /dev/null +++ b/nvim/.config/nvim/lua/plugins.lua @@ -0,0 +1,40 @@ +-- This file can be loaded by calling `lua require('plugins')` from your init.vim + +-- Only required if you have packer configured as `opt` +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + use({'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}) + use { + 'VonHeikemen/lsp-zero.nvim', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + } + } + use { "junegunn/fzf", run = ":call fzf#install()" } + use 'airblade/vim-gitgutter' + use 'tpope/vim-commentary' + use 'sh-ubh/vim-bujo' + use { + 'windwp/nvim-autopairs', + config = function() require("nvim-autopairs").setup {} end + } + +end) diff --git a/nvim/.config/nvim/lua/set.lua b/nvim/.config/nvim/lua/set.lua new file mode 100644 index 0000000..923eb9a --- /dev/null +++ b/nvim/.config/nvim/lua/set.lua @@ -0,0 +1,55 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.syntax = "enable" +vim.opt.cursorline = true +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.wildmenu = true +vim.opt.autoread = true + +vim.cmd('colorscheme plain') + +-- gitgutter options +vim.g.gitgutter_override_sign_column_highlight = 0 +vim.g.gitgutter_sign_added = '+' +vim.g.gitgutter_sign_modified = '±' +vim.g.gitgutter_sign_removed = '-' +vim.g.gitgutter_sign_removed_first_line = '^' +vim.g.gitgutter_sign_modified_removed = '#' + +-- netrw options +vim.g.netrw_browse_split = 0 +vim.g.netrw_banner = 0 +vim.g.netrw_winsize = 25 + +-- set statusline +stl = require('statusline.line') +vim.opt.statusline = '%!luaeval("stl.statusline()")' diff --git a/nvim/.config/nvim/lua/statusline/git.lua b/nvim/.config/nvim/lua/statusline/git.lua new file mode 100644 index 0000000..4d3492c --- /dev/null +++ b/nvim/.config/nvim/lua/statusline/git.lua @@ -0,0 +1,45 @@ +local M = {} + +local sep = package.config:sub(1,1) + +local function find_git_dir() + local file_dir = vim.fn.expand('%:p:h') .. ';' + local git_dir = vim.fn.finddir('.git', file_dir) + if #git_dir > 0 then + M.in_git = true + end + return git_dir +end + +local function get_git_head(head_file) + local f_head = io.open(head_file) + if f_head then + local HEAD = f_head:read() + f_head:close() + local branch = HEAD:match('ref: refs/heads/(.+)$') + if branch then M.git_branch = branch + else M.git_branch = HEAD:sub(1,7) end + end + return nil +end + +-- event watcher to watch head file +local file_changed = vim.loop.new_fs_event() +local function watch_head() + file_changed:stop() + local git_dir = find_git_dir() + if #git_dir > 0 then + local head_file = git_dir..sep..'HEAD' + get_git_head(head_file) + file_changed:start(head_file, {}, vim.schedule_wrap(function() + -- reset file-watch + watch_head() + end)) + else + M.git_branch = '' + end +end + +watch_head() + +return M diff --git a/nvim/.config/nvim/lua/statusline/line.lua b/nvim/.config/nvim/lua/statusline/line.lua new file mode 100644 index 0000000..f70c2f8 --- /dev/null +++ b/nvim/.config/nvim/lua/statusline/line.lua @@ -0,0 +1,32 @@ +local git = require('statusline.git') +local utils = require('utils') +local M = {} + +-- set highlights for statusline sections +vim.api.nvim_exec( +[[ + hi PrimaryBlock ctermfg=06 ctermbg=00 + hi SecondaryBlock ctermfg=07 ctermbg=00 + hi Blanks ctermfg=08 ctermbg=00 + hi GitClean ctermfg=02 ctermbg=00 + hi GitDirty ctermfg=01 ctermbg=00 +]], false) + +function M.statusline() + local stl = { + '%#PrimaryBlock#', + '%f', + '%#Blanks#', + '%m', + '%#SecondaryBlock#', + ' '..git.git_branch, + '%=', + '%#SecondaryBlock#', + '%l,%c ', + '%#PrimaryBlock#', + '%{&filetype}', + } + return table.concat(stl) +end + +return M diff --git a/nvim/.config/nvim/lua/utils.lua b/nvim/.config/nvim/lua/utils.lua new file mode 100644 index 0000000..84b4b8d --- /dev/null +++ b/nvim/.config/nvim/lua/utils.lua @@ -0,0 +1,18 @@ +local M = {} +local cmd = vim.cmd + +function M.create_augroup(autocmds, name) + cmd('augroup ' .. name) + cmd('autocmd!') + for _, autocmd in ipairs(autocmds) do + cmd('autocmd ' .. table.concat(autocmd, ' ')) + end + cmd('augroup END') +end + +function M.iabbrev(a, b) + cmd(string.format('iabbrev %s %s', a, b)) +end + +return M + diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..9d2bf07 --- /dev/null +++ b/nvim/.config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,194 @@ +-- 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() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +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 + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/var/home/shubh/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/var/home/shubh/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/var/home/shubh/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/var/home/shubh/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/var/home/shubh/.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 = { + LuaSnip = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["cmp-buffer"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["friendly-snippets"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + fzf = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/fzf", + url = "https://github.com/junegunn/fzf" + }, + ["lsp-zero.nvim"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", + url = "https://github.com/VonHeikemen/lsp-zero.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["nvim-autopairs"] = { + config = { "\27LJ\2\n@\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\19nvim-autopairs\frequire\0" }, + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["packer.nvim"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["vim-bujo"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/vim-bujo", + url = "https://github.com/sh-ubh/vim-bujo" + }, + ["vim-commentary"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/vim-commentary", + url = "https://github.com/tpope/vim-commentary" + }, + ["vim-gitgutter"] = { + loaded = true, + path = "/var/home/shubh/.local/share/nvim/site/pack/packer/start/vim-gitgutter", + url = "https://github.com/airblade/vim-gitgutter" + } +} + +time([[Defining packer_plugins]], false) +-- Config for: nvim-autopairs +time([[Config for nvim-autopairs]], true) +try_loadstring("\27LJ\2\n@\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\19nvim-autopairs\frequire\0", "config", "nvim-autopairs") +time([[Config for nvim-autopairs]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = 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 -- cgit v1.2.3