diff options
-rw-r--r-- | init.lua | 4 | ||||
-rw-r--r-- | lua/colorscheme.lua | 2 | ||||
-rw-r--r-- | lua/lv-autopairs/init.lua | 78 | ||||
-rw-r--r-- | lua/lv-comment/init.lua | 1 | ||||
-rw-r--r-- | lua/lv-compe/init.lua | 54 | ||||
-rw-r--r-- | lua/lv-gitsigns/init.lua | 77 | ||||
-rw-r--r-- | lua/lv-nvimtree/init.lua | 154 | ||||
-rw-r--r-- | lua/lv-which-key/init.lua | 2 | ||||
-rw-r--r-- | lua/plugins.lua | 168 | ||||
-rw-r--r-- | lua/settings.lua | 1 |
10 files changed, 265 insertions, 276 deletions
@@ -5,12 +5,8 @@ require('plugins') require('lv-utils') require('lv-autocommands') require('keymappings') -require('lv-nvimtree') -- This plugin must be required somewhere before colorscheme. Placing it after will break navigation keymappings require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings require('lv-galaxyline') -require('lv-comment') -require('lv-compe') -require('lv-barbar') require('lv-telescope') require('lv-gitsigns') require('lv-treesitter') diff --git a/lua/colorscheme.lua b/lua/colorscheme.lua index bfd467f1..8109f50d 100644 --- a/lua/colorscheme.lua +++ b/lua/colorscheme.lua @@ -1,3 +1,3 @@ -vim.cmd('let g:nvcode_termcolors=256') +-- vim.cmd('let g:nvcode_termcolors=256') vim.cmd('colorscheme ' .. O.colorscheme) diff --git a/lua/lv-autopairs/init.lua b/lua/lv-autopairs/init.lua index 8a26f138..d9caf22f 100644 --- a/lua/lv-autopairs/init.lua +++ b/lua/lv-autopairs/init.lua @@ -1,81 +1,3 @@ --- require('nvim-autopairs').setup() --- local npairs = require('nvim-autopairs') - --- local function imap(lhs, rhs, opts) --- local options = {noremap = false} --- if opts then options = vim.tbl_extend('force', options, opts) end --- vim.api.nvim_set_keymap('i', lhs, rhs, options) --- end - --- _G.MUtils = {} - --- -- TEST --- vim.g.completion_confirm_key = "" --- MUtils.completion_confirm = function() --- if vim.fn.pumvisible() ~= 0 then --- if vim.fn.complete_info()["selected"] ~= -1 then --- vim.fn["compe#confirm"]() --- -- return npairs.esc("<c-y>") --- return npairs.esc("") --- else --- vim.defer_fn(function() --- vim.fn["compe#confirm"]("<cr>") --- end, 20) --- return npairs.esc("<c-n>") --- end --- else --- return npairs.check_break_line_char() --- end --- end --- -- TEST - --- MUtils.completion_confirm = function() --- if vim.fn.pumvisible() ~= 0 then --- if vim.fn.complete_info()["selected"] ~= -1 then --- vim.fn["compe#confirm"]() --- return npairs.esc("") --- else --- vim.api.nvim_select_popupmenu_item(0, false, false, {}) --- vim.fn["compe#confirm"]() --- return npairs.esc("<c-n>") --- end --- else --- return npairs.check_break_line_char() --- end --- end - --- MUtils.tab = function() --- if vim.fn.pumvisible() ~= 0 then --- return npairs.esc("<C-n>") --- else --- if vim.fn["vsnip#available"](1) ~= 0 then --- vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83)) --- return npairs.esc("") --- else --- return npairs.esc("<Tab>") --- end --- end --- end - --- MUtils.s_tab = function() --- if vim.fn.pumvisible() ~= 0 then --- return npairs.esc("<C-p>") --- else --- if vim.fn["vsnip#jumpable"](-1) ~= 0 then --- vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83)) --- return npairs.esc("") --- else --- return npairs.esc("<C-h>") --- end --- end --- end - --- -- Autocompletion and snippets --- vim.api.nvim_set_keymap('i', '<CR>', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true}) --- -- imap("<CR>", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) --- imap("<Tab>", "v:lua.MUtils.tab()", {expr = true, noremap = true}) --- imap("<S-Tab>", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) - local remap = vim.api.nvim_set_keymap local npairs = require('nvim-autopairs') local Rule = require('nvim-autopairs.rule') diff --git a/lua/lv-comment/init.lua b/lua/lv-comment/init.lua deleted file mode 100644 index e1f13586..00000000 --- a/lua/lv-comment/init.lua +++ /dev/null @@ -1 +0,0 @@ -require('nvim_comment').setup() diff --git a/lua/lv-compe/init.lua b/lua/lv-compe/init.lua index 7a5a4b1d..54ef2310 100644 --- a/lua/lv-compe/init.lua +++ b/lua/lv-compe/init.lua @@ -1,5 +1,6 @@ -vim.o.completeopt = "menuone,noselect" +local M = {} +M.config = function() require'compe'.setup { enabled = O.auto_complete, autocomplete = true, @@ -59,54 +60,6 @@ require'compe'.setup { -- -- --- local t = function(str) --- return vim.api.nvim_replace_termcodes(str, true, true, true) --- end - --- local check_back_space = function() --- local col = vim.fn.col('.') - 1 --- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then --- return true --- else --- return false --- end --- end - --- -- Use (s-)tab to: --- --- move to prev/next item in completion menuone --- --- jump to prev/next snippet's placeholder --- _G.tab_complete = function() --- if vim.fn.pumvisible() == 1 then --- return t "<C-n>" --- elseif vim.fn.call("vsnip#available", {1}) == 1 then --- return t "<Plug>(vsnip-expand-or-jump)" --- elseif check_back_space() then --- return t "<Tab>" --- else --- return vim.fn['compe#complete']() --- end --- end --- _G.s_tab_complete = function() --- if vim.fn.pumvisible() == 1 then --- return t "<C-p>" --- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then --- return t "<Plug>(vsnip-jump-prev)" --- else --- return t "<S-Tab>" --- end --- end - --- vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) --- vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) --- vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) --- vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) - - - - - - - local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end @@ -154,3 +107,6 @@ vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", {noremap = true, s vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", {noremap = true, silent = true, expr = true}) vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({ 'delta': +4 })", {noremap = true, silent = true, expr = true}) vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({ 'delta': -4 })", {noremap = true, silent = true, expr = true}) +end + +return M diff --git a/lua/lv-gitsigns/init.lua b/lua/lv-gitsigns/init.lua index c19a5d00..7f0db565 100644 --- a/lua/lv-gitsigns/init.lua +++ b/lua/lv-gitsigns/init.lua @@ -1,24 +1,53 @@ -require('gitsigns').setup { - signs = { - -- TODO add hl to colorscheme - add = {hl = 'GitSignsAdd' , text = '▎', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - }, - numhl = false, - linehl = false, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - }, - watch_index = { - interval = 1000 - }, - sign_priority = 6, - update_debounce = 200, - status_formatter = nil, -- Use default - use_decoration_api = false -} +local M = {} + +M.config = function() + require('gitsigns').setup { + signs = { + -- TODO add hl to colorscheme + add = { + hl = 'GitSignsAdd', + text = '▎', + numhl = 'GitSignsAddNr', + linehl = 'GitSignsAddLn' + }, + change = { + hl = 'GitSignsChange', + text = '▎', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn' + }, + delete = { + hl = 'GitSignsDelete', + text = '契', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn' + }, + topdelete = { + hl = 'GitSignsDelete', + text = '契', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn' + }, + changedelete = { + hl = 'GitSignsChange', + text = '▎', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn' + } + }, + numhl = false, + linehl = false, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true + }, + watch_index = {interval = 1000}, + sign_priority = 6, + update_debounce = 200, + status_formatter = nil, -- Use default + use_decoration_api = false + } +end + +return M diff --git a/lua/lv-nvimtree/init.lua b/lua/lv-nvimtree/init.lua index 4b8c3973..5479b86f 100644 --- a/lua/lv-nvimtree/init.lua +++ b/lua/lv-nvimtree/init.lua @@ -1,82 +1,88 @@ ---[[ " ---let g:nvim_tree_auto_ignore_ft = 'startify' "empty by default, don't auto open tree on specific filetypes. -let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.` -let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). -" let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open -" let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file -let g:nvim_tree_show_icons = { - \ 'git': 1, - \ 'folders': 1, - \ 'files': 1, - \ } +local M = {} -"If 0, do not show the icons for one of 'git' 'folder' and 'files' -"1 by default, notice that if 'files' is 1, it will only display -"if nvim-web-devicons is installed and on your runtimepath ]] -- vim.g.nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default -vim.g.nvim_tree_disable_netrw = 1 -- moved to lv-globals -vim.g.nvim_tree_hijack_netrw = 1 --"1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities) -vim.g.nvim_tree_hide_dotfiles = 1 -- 0 by default, this option hides files and folders starting with a dot `.` -vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open -vim.g.nvim_tree_follow = 1 -- "0 by default, this option allows the cursor to be updated when entering a buffer -vim.g.nvim_tree_auto_close = O.auto_close_tree -- 0 by default, closes the tree when it's the last window -vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes. -vim.g.nvim_tree_quit_on_open = 0 -- this doesn't play well with barbar -local tree_cb = require'nvim-tree.config'.nvim_tree_callback - vim.g.nvim_tree_bindings = { - -- ["<CR>"] = ":YourVimFunction()<cr>", - -- ["u"] = ":lua require'some_module'.some_function()<cr>", +M.config = function() + local g = vim.g - -- default mappings - ["<CR>"] = tree_cb("edit"), - ["o"] = tree_cb("edit"), - ["l"] = tree_cb("edit"), - ["<2-LeftMouse>"] = tree_cb("edit"), - ["<2-RightMouse>"] = tree_cb("cd"), - ["<C-]>"] = tree_cb("cd"), - ["v"] = tree_cb("vsplit"), - ["s"] = tree_cb("split"), - ["<C-t>"] = tree_cb("tabnew"), - ["<"] = tree_cb("prev_sibling"), - [">"] = tree_cb("next_sibling"), - ["<BS>"] = tree_cb("close_node"), - ["h"] = tree_cb("close_node"), - ["<S-CR>"] = tree_cb("close_node"), - ["<Tab>"] = tree_cb("preview"), - ["I"] = tree_cb("toggle_ignored"), - ["H"] = tree_cb("toggle_dotfiles"), - ["R"] = tree_cb("refresh"), - ["a"] = tree_cb("create"), - ["d"] = tree_cb("remove"), - ["r"] = tree_cb("rename"), - ["<C-r>"] = tree_cb("full_rename"), - ["x"] = tree_cb("cut"), - ["c"] = tree_cb("copy"), - ["p"] = tree_cb("paste"), - ["[c"] = tree_cb("prev_git_item"), - ["]c"] = tree_cb("next_git_item"), - ["-"] = tree_cb("dir_up"), - ["q"] = tree_cb("close"), + vim.o.termguicolors = true + + g.nvim_tree_side = "left" + g.nvim_tree_width = 25 + g.nvim_tree_ignore = {".git", "node_modules", ".cache"} + g.nvim_tree_auto_open = 0 + g.nvim_tree_auto_close = 0 + g.nvim_tree_quit_on_open = 0 + g.nvim_tree_follow = 1 + g.nvim_tree_indent_markers = 1 + g.nvim_tree_hide_dotfiles = 1 + g.nvim_tree_git_hl = 1 + g.nvim_tree_root_folder_modifier = ":t" + g.nvim_tree_tab_open = 0 + g.nvim_tree_allow_resize = 1 + + g.nvim_tree_show_icons = { + git = 1, + folders = 1, + files = 1 } --- vim.g.nvim_tree_show_icons = {git = 1, folders = 1, files = 1} -vim.g.nvim_tree_icons = { - default = '', - symlink = '', - git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""}, - folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""} -} -local view = require'nvim-tree.view' + g.nvim_tree_icons = { + default = "", + symlink = "", + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌" + }, + folder = { + default = "", + open = "", + symlink = "", + empty = "", + empty_open = "", + symlink_open = "" + } + } -local _M = {} -_M.toggle_tree = function() - if view.win_open() then - require'nvim-tree'.close() - require'bufferline.state'.set_offset(0) - else - require'bufferline.state'.set_offset(31, 'File Explorer') - require'nvim-tree'.find_file(true) - end + local tree_cb = require "nvim-tree.config".nvim_tree_callback + g.nvim_tree_bindings = { + ["u"] = ":lua require'some_module'.some_function()<cr>", + -- default mappings + ["<CR>"] = tree_cb("edit"), + ["o"] = tree_cb("edit"), + ["<2-LeftMouse>"] = tree_cb("edit"), + ["<2-RightMouse>"] = tree_cb("cd"), + ["<C-]>"] = tree_cb("cd"), + ["<C-v>"] = tree_cb("vsplit"), + ["<C-x>"] = tree_cb("split"), + ["<C-t>"] = tree_cb("tabnew"), + ["<"] = tree_cb("prev_sibling"), + [">"] = tree_cb("next_sibling"), + ["<BS>"] = tree_cb("close_node"), + ["<S-CR>"] = tree_cb("close_node"), + ["<Tab>"] = tree_cb("preview"), + ["I"] = tree_cb("toggle_ignored"), + ["H"] = tree_cb("toggle_dotfiles"), + ["R"] = tree_cb("refresh"), + ["a"] = tree_cb("create"), + ["d"] = tree_cb("remove"), + ["r"] = tree_cb("rename"), + ["<C-r>"] = tree_cb("full_rename"), + ["x"] = tree_cb("cut"), + ["c"] = tree_cb("copy"), + ["p"] = tree_cb("paste"), + ["y"] = tree_cb("copy_name"), + ["Y"] = tree_cb("copy_path"), + ["gy"] = tree_cb("copy_absolute_path"), + ["[c"] = tree_cb("prev_git_item"), + ["]c"] = tree_cb("next_git_item"), + ["-"] = tree_cb("dir_up"), + ["q"] = tree_cb("close") + } end -return _M +return M diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index cb756e55..cce960c3 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -56,7 +56,7 @@ local opts = { vim.api.nvim_set_keymap('n', '<Leader>h', ':let @/=""<CR>', {noremap = true, silent = true}) -- explorer -vim.api.nvim_set_keymap('n', '<Leader>e', ":lua require'lv-nvimtree'.toggle_tree()<CR>", {noremap = true, silent = true}) +vim.api.nvim_set_keymap('n', '<Leader>e', ":NvimTreeToggle<CR>", {noremap = true, silent = true}) -- telescope vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', {noremap = true, silent = true}) diff --git a/lua/plugins.lua b/lua/plugins.lua index 49cb8697..5973bcb5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -34,16 +34,55 @@ return require("packer").startup(function(use) use "wbthomason/packer.nvim" -- TODO refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function) - use {"neovim/nvim-lspconfig", event = "BufRead", opt = true} - use {"glepnir/lspsaga.nvim", event = "BufRead", opt = true} - use {"kabouzeid/nvim-lspinstall", opt = true} + use { + "neovim/nvim-lspconfig", + + -- event = "BufRead", + + -- opt = true + } + use { + "glepnir/lspsaga.nvim", + + -- event = "BufRead", + + -- opt = true + } + use {"kabouzeid/nvim-lspinstall", + + -- opt = true + +} -- Telescope - use {"nvim-lua/popup.nvim", opt = true} - use {"nvim-lua/plenary.nvim", opt = true} - use {"nvim-telescope/telescope.nvim", cmd = "Telescope", opt = true} + use {"nvim-lua/popup.nvim", + + -- opt = true + +} + use {"nvim-lua/plenary.nvim", + + -- opt = true + +} + use { + "nvim-telescope/telescope.nvim", + + -- cmd = "Telescope", + + -- opt = true + } -- Autocomplete - use {"hrsh7th/nvim-compe", event = "InsertEnter", opt = true} + use { + "hrsh7th/nvim-compe", + config = function() + -- require_plugin("nvim-compe") + require("lv-compe").config() + end, + -- event = "InsertEnter", + + -- opt = true + } -- Treesitter use { @@ -57,62 +96,103 @@ return require("packer").startup(function(use) -- Explorer -- use {"kyazdani42/nvim-tree.lua", opt = true} - use {"kyazdani42/nvim-tree.lua", opt = true, cmd = "NvimTreeToggle"} + use { + "kyazdani42/nvim-tree.lua", + -- cmd = "NvimTreeToggle", + config = function() + -- require_plugin("lv-nvimtree") + require("lv-nvimtree").config() + end, + + -- opt = true + } -- use {'lukas-reineke/indent-blankline.nvim', opt=true, branch = 'lua'} - use {"lewis6991/gitsigns.nvim", event = "BufRead", opt = true} + use {"lewis6991/gitsigns.nvim", + + -- event = "BufRead", + - use {"folke/which-key.nvim", opt = true} - use {"windwp/nvim-autopairs", event = "InsertEnter", opt = true} + -- opt = true + + } + + use {"folke/which-key.nvim", + + -- opt = true + + } + use {"windwp/nvim-autopairs", + config = function() + -- require_plugin("lv-nvimtree") + require("lv-autopairs").config() + end, + + -- event = "InsertEnter", + + -- opt = true + + } -- Comments use { "terrortylor/nvim-comment", cmd = "CommentToggle", - config = require_plugin("nvim-comment"), - opt = true + config = function() + require('nvim_comment').setup() + end, + -- opt = true } -- Color - use { - "christianchiarulli/nvcode-color-schemes.vim", - config = require_plugin("nvcode-color-schemes.vim"), - opt = true - } + use {"christianchiarulli/nvcode-color-schemes.vim", opt = true} -- Icons - use { - "kyazdani42/nvim-web-devicons", - config = require_plugin("nvim-web-devicons"), - opt = true + use {"kyazdani42/nvim-web-devicons", + -- opt = true + } -- Status Line and Bufferline - use { - "glepnir/galaxyline.nvim", - config = require_plugin("galaxyline.nvim"), - opt = true + use {"glepnir/galaxyline.nvim", + + -- opt = true } - use { - "romgrk/barbar.nvim", - config = require_plugin("barbar.nvim"), - opt = true + + use {"romgrk/barbar.nvim", + + config = function() + -- require_plugin("barbar.nvim") + vim.api.nvim_set_keymap('n', '<TAB>', ':BufferNext<CR>', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferPrevious<CR>', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '<S-x>', ':BufferClose<CR>', { noremap = true, silent = true }) + end, + + -- opt = true + + } + + use {"hrsh7th/vim-vsnip", + + -- opt = true + } - use {"hrsh7th/vim-vsnip", config = require_plugin("vim-vsnip"), opt = true} - - require_plugin("nvim-lspconfig") - require_plugin("lspsaga.nvim") - require_plugin("nvim-lspinstall") - require_plugin("popup.nvim") - require_plugin("plenary.nvim") - require_plugin("telescope.nvim") - require_plugin("nvim-compe") - require_plugin("nvim-treesitter") - require_plugin("nvim-tree.lua") - require_plugin("gitsigns.nvim") - require_plugin("which-key.nvim") - require_plugin("nvim-autopairs") + -- require_plugin("nvim-lspconfig") + -- require_plugin("lspsaga.nvim") + -- require_plugin("nvim-lspinstall") + -- require_plugin("popup.nvim") + -- require_plugin("plenary.nvim") + -- require_plugin("telescope.nvim") + -- require_plugin("nvim-treesitter") + -- require_plugin("nvim-comment") + -- require_plugin("nvim-tree.lua") + -- require_plugin("gitsigns.nvim") + -- require_plugin("which-key.nvim") + -- require_plugin("nvim-autopairs") + -- require_plugin("nvim-web-devicons") + -- require_plugin("galaxyline.nvim") + -- require_plugin("vim-vsnip") -- Extras if O.extras then diff --git a/lua/settings.lua b/lua/settings.lua index 1c36405e..94a1fc3e 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -22,6 +22,7 @@ vim.o.conceallevel = 0 -- So that I can see `` in markdown files vim.cmd('set ts=4') -- Insert 2 spaces for a tab vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation vim.cmd('set expandtab') -- Converts tabs to spaces +vim.o.completeopt = "menuone,noselect" vim.bo.smartindent = true -- Makes indenting smart vim.wo.number = O.number -- set numbered lines vim.wo.relativenumber = O.relative_number -- set relative number |