Просмотр исходного кода

add some useful plugins to base config and a option to enable extras

christianchiarulli 4 лет назад
Родитель
Сommit
66501fefe7

+ 14 - 1
init.lua

@@ -1,6 +1,7 @@
 require('lv-globals')
 vim.cmd('luafile '..CONFIG_PATH..'/lv-settings.lua')
 require('settings')
+require('lv-gitblame')
 require('plugins')
 require('lv-utils')
 require('lv-autocommands')
@@ -9,15 +10,28 @@ require('lv-nvimtree') -- This plugin must be required somewhere before colorsch
 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-gitblame')
 require('lv-compe')
 require('lv-barbar')
 require('lv-dashboard')
 require('lv-telescope')
 require('lv-gitsigns')
 require('lv-treesitter')
+require('lv-matchup')
 require('lv-autopairs')
 require('lv-rnvimr')
 require('lv-which-key')
+require('lv-lsp-rooter')
+require('lv-zen')
+
+-- extras
+if O.extras then
+    require('lv-numb')
+    require('lv-hop')
+    require('lv-colorizer')
+end
+
+
 
 -- TODO is there a way to do this without vimscript
 vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim')
@@ -52,4 +66,3 @@ require('lsp.vim-ls')
 require('lsp.vue-ls')
 require('lsp.yaml-ls')
 require('lsp.elixir-ls')
-

+ 5 - 1
lua/keymappings.lua

@@ -48,9 +48,13 @@ vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', {noremap = true, silen
 vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
 vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
 
--- fix to get netrw's gx command to work correctly 
+-- fix to get netrw's gx command to work correctly
 vim.api.nvim_set_keymap('n', 'gx', ":call netrw#BrowseX(expand((exists('g:netrw_gx')? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())<cr>", {noremap = true, silent = true})
 
+vim.cmd('vnoremap p "0p')
+vim.cmd('vnoremap P "0P')
+-- vim.api.nvim_set_keymap('v', 'p', '"0p', {silent = true})
+-- vim.api.nvim_set_keymap('v', 'P', '"0P', {silent = true})
 
 -- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
 -- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')

+ 13 - 0
lua/lv-colorizer/init.lua

@@ -0,0 +1,13 @@
+require'colorizer'.setup(
+  {'*';},
+  {
+    RGB      = true;         -- #RGB hex codes
+    RRGGBB   = true;         -- #RRGGBB hex codes
+    RRGGBBAA = true;         -- #RRGGBBAA hex codes
+    rgb_fn   = true;         -- CSS rgb() and rgba() functions
+    hsl_fn   = true;         -- CSS hsl() and hsla() functions
+    css      = true;         -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
+    css_fn   = true;         -- Enable all CSS *functions*: rgb_fn, hsl_fn
+  })
+	  -- names    = true;         -- "Name" codes like Blue
+

+ 2 - 0
lua/lv-gitblame/init.lua

@@ -0,0 +1,2 @@
+vim.cmd('highlight default link gitblame SpecialComment')
+vim.g.gitblame_enabled = 0

+ 3 - 2
lua/lv-globals.lua

@@ -11,8 +11,9 @@ O = {
     number = true,
     relative_number = true,
     shell = 'bash',
-	  timeoutlen = 100,
-    nvim_tree_disable_netrw = 0, 
+	timeoutlen = 100,
+    nvim_tree_disable_netrw = 0,
+    extras = false,
 
     -- @usage pass a table with your desired languages
     treesitter = {

+ 2 - 0
lua/lv-hop/init.lua

@@ -0,0 +1,2 @@
+vim.api.nvim_set_keymap('n', 's', ":HopChar2<cr>", {silent = true})
+vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", {silent = true})

+ 5 - 0
lua/lv-lsp-rooter/init.lua

@@ -0,0 +1,5 @@
+require("lsp-rooter").setup {
+      -- your configuration comes here
+      -- or leave it empty to use the default settings
+      -- refer to the configuration section below
+    }

+ 2 - 0
lua/lv-matchup/init.lua

@@ -0,0 +1,2 @@
+vim.g.matchup_matchparen_offscreen = {method = 'popup'}
+

+ 4 - 0
lua/lv-numb/init.lua

@@ -0,0 +1,4 @@
+require('numb').setup{
+   show_numbers = true, -- Enable 'number' for the window while peeking
+   show_cursorline = true -- Enable 'cursorline' for the window while peeking
+}

+ 4 - 0
lua/lv-quickscope/init.lua

@@ -0,0 +1,4 @@
+-- Trigger a highlight in the appropriate direction when pressing these keys:
+-- vim.cmd('let g:qs_highlight_on_keys = [\'f\', \'F\', \'t\', \'T\']')
+vim.g.qs_highlight_on_keys = {'f', 'F', 't', 'T'}
+vim.g.qs_max_chars=150

+ 10 - 8
lua/lv-telescope/init.lua

@@ -1,4 +1,5 @@
 local actions = require('telescope.actions')
+local trouble = require("trouble.providers.telescope")
 -- Global remapping
 ------------------------------
 -- '--color=never',
@@ -11,6 +12,7 @@ require('telescope').setup {
         selection_caret = " ",
         entry_prefix = "  ",
         initial_mode = "insert",
+        -- initial_mode = "insert",
         selection_strategy = "reset",
         sorting_strategy = "descending",
         layout_strategy = "horizontal",
@@ -37,13 +39,15 @@ require('telescope').setup {
         buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
         mappings = {
             i = {
+                ["<C-c>"] = actions.close,
                 ["<C-j>"] = actions.move_selection_next,
                 ["<C-k>"] = actions.move_selection_previous,
+                ["<c-t>"] = trouble.open_with_trouble,
                 ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
                 -- To disable a keymap, put [map] = false
                 -- So, to not map "<C-n>", just put
                 -- ["<c-x>"] = false,
-                ["<esc>"] = actions.close,
+                -- ["<esc>"] = actions.close,
 
                 -- Otherwise, just set the mapping to the function that you want it to be.
                 -- ["<C-i>"] = actions.select_horizontal,
@@ -57,15 +61,13 @@ require('telescope').setup {
             n = {
                 ["<C-j>"] = actions.move_selection_next,
                 ["<C-k>"] = actions.move_selection_previous,
-                ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
+                ["<c-t>"] = trouble.open_with_trouble,
+                ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist
                 -- ["<C-i>"] = my_cool_custom_action,
             }
         }
     },
-    extensions = {
-        fzy_native = {
-            override_generic_sorter = false,
-            override_file_sorter = true,
-        }
-    }
+    extensions = {fzy_native = {override_generic_sorter = false, override_file_sorter = true}}
 }
+
+require'telescope'.load_extension('project')

+ 10 - 0
lua/lv-treesitter/init.lua

@@ -1,9 +1,19 @@
 require'nvim-treesitter.configs'.setup {
     ensure_installed = O.treesitter.ensure_installed, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
     ignore_install = O.treesitter.ignore_install,
+    matchup = {
+        enable = true,              -- mandatory, false will disable the whole extension
+        -- disable = { "c", "ruby" },  -- optional, list of language that will be disabled
+    },
     highlight = {
         enable = O.treesitter.highlight.enabled -- false will disable the whole extension
     },
+    context_commentstring = {
+        enable = true,
+        config = {
+          css = '// %s'
+        }
+      },
     -- indent = {enable = true, disable = {"python", "html", "javascript"}},
     -- TODO seems to be broken
     indent = {enable = {"javascriptreact"}},

+ 25 - 5
lua/lv-which-key/init.lua

@@ -5,9 +5,9 @@ require("which-key").setup {
         -- the presets plugin, adds help for a bunch of default keybindings in Neovim
         -- No actual key bindings are created
         presets = {
-            operators = true, -- adds help for operators like d, y, ...
-            motions = true, -- adds help for motions
-            text_objects = true, -- help for text objects triggered after entering an operator
+            operators = false, -- adds help for operators like d, y, ...
+            motions = false, -- adds help for motions
+            text_objects = false, -- help for text objects triggered after entering an operator
             windows = true, -- default bindings on <c-w>
             nav = true, -- misc bindings to work with windows
             z = true, -- bindings for folds, spelling and others prefixed with z
@@ -66,6 +66,9 @@ vim.api.nvim_set_keymap("v", "<leader>/", ":CommentToggle<CR>", {noremap = true,
 -- close buffer
 vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", {noremap = true, silent = true})
 
+-- open projects
+vim.api.nvim_set_keymap('n', '<leader>p', ":lua require'telescope'.extensions.project.project{}<CR>",
+                        {noremap = true, silent = true})
 -- TODO create entire treesitter section
 
 local mappings = {
@@ -74,7 +77,17 @@ local mappings = {
     ["e"] = "Explorer",
     ["f"] = "Find File",
     ["h"] = "No Highlight",
+    ["p"] = "Projects",
     d = {
+        name = "+Diagnostics",
+        t = {"<cmd>TroubleToggle<cr>", "trouble"},
+        w = {"<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace"},
+        d = {"<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document"},
+        q = {"<cmd>TroubleToggle quickfix<cr>", "quickfix"},
+        l = {"<cmd>TroubleToggle loclist<cr>", "loclist"},
+        r = {"<cmd>TroubleToggle lsp_references<cr>", "references"},
+    },
+    D = {
         name = "+Debug",
         b = {"<cmd>DebugToggleBreakpoint<cr>", "Toggle Breakpoint"},
         c = {"<cmd>DebugContinue<cr>", "Continue"},
@@ -115,7 +128,6 @@ local mappings = {
         s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"},
         S = {"<cmd>Telescope lsp_workspace_symbols<cr>", "Workspace Symbols"}
     },
-
     s = {
         name = "+Search",
         b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"},
@@ -129,7 +141,15 @@ local mappings = {
         R = {"<cmd>Telescope registers<cr>", "Registers"},
         t = {"<cmd>Telescope live_grep<cr>", "Text"}
     },
-    S = {name = "+Session", s = {"<cmd>SessionSave<cr>", "Save Session"}, l = {"<cmd>SessionLoad<cr>", "Load Session"}}
+    S = {name = "+Session", s = {"<cmd>SessionSave<cr>", "Save Session"}, l = {"<cmd>SessionLoad<cr>", "Load Session"}},
+
+    -- extras
+    z = {
+        name = "+Zen",
+        s = {"<cmd>TZBottom<cr>", "toggle status line"},
+        t = {"<cmd>TZTop<cr>", "toggle tab bar"},
+        z = {"<cmd>TZAtaraxis<cr>", "toggle zen"},
+    }
 }
 
 local wk = require("which-key")

+ 53 - 0
lua/lv-zen/init.lua

@@ -0,0 +1,53 @@
+-- setup for TrueZen.nvim
+require("true-zen").setup({
+    true_false_commands = false,
+	cursor_by_mode = false,
+	before_minimalist_mode_shown = false,
+	before_minimalist_mode_hidden = false,
+	after_minimalist_mode_shown = false,
+	after_minimalist_mode_hidden = false,
+	bottom = {
+		hidden_laststatus = 0,
+		hidden_ruler = false,
+		hidden_showmode = false,
+		hidden_showcmd = false,
+		hidden_cmdheight = 1,
+
+		shown_laststatus = 2,
+		shown_ruler = true,
+		shown_showmode = false,
+		shown_showcmd = false,
+		shown_cmdheight = 1
+	},
+	top = {
+		hidden_showtabline = 0,
+
+		shown_showtabline = 2
+	},
+	left = {
+		hidden_number = false,
+		hidden_relativenumber = false,
+		hidden_signcolumn = "no",
+
+		shown_number = true,
+		shown_relativenumber = false,
+		shown_signcolumn = "no"
+	},
+	ataraxis = {
+		just_do_it_for_me = false,
+		left_padding = 10,
+		right_padding = 10,
+		top_padding = 1,
+		bottom_padding = 1
+	},
+	integrations = {
+		integration_galaxyline = true,
+		integration_vim_airline = false,
+		integration_vim_powerline = false,
+		integration_tmux = false,
+		integration_express_line = false,
+		integration_gitgutter = false,
+		integration_vim_signify = false,
+		integration_limelight = false
+	}
+})

+ 129 - 79
lua/plugins.lua

@@ -22,88 +22,138 @@ local function require_plugin(plugin)
         end
     end
     --	print(ok, err, code)
-    if ok then
-        vim.cmd("packadd " .. plugin)
-    end
+    if ok then vim.cmd("packadd " .. plugin) end
     return ok, err, code
 end
 
 vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" -- Auto compile when there are changes in plugins.lua
 
-return require("packer").startup(
-    function(use)
-        -- Packer can manage itself as an optional plugin
-        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", opt = true}
-        use {"glepnir/lspsaga.nvim", 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", opt = true}
-        use {"nvim-telescope/telescope-fzy-native.nvim", opt = true}
-
-        -- Debugging
-        use {"mfussenegger/nvim-dap", opt = true}
-
-        -- Autocomplete
-        use {"hrsh7th/nvim-compe", opt = true}
-        use {"hrsh7th/vim-vsnip", opt = true}
-        use {"rafamadriz/friendly-snippets", opt = true}
-
-        -- Treesitter
-        use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
-        use {"windwp/nvim-ts-autotag", opt = true}
-
-        -- Explorer
-        use {"kyazdani42/nvim-tree.lua", opt = true}
-        -- TODO remove when open on dir is supported by nvimtree
-        use "kevinhwang91/rnvimr"
-
-        -- use {'lukas-reineke/indent-blankline.nvim', opt=true, branch = 'lua'}
-        use {"lewis6991/gitsigns.nvim", opt = true}
-        -- use {"liuchengxu/vim-which-key", opt = true}
-        use {"folke/which-key.nvim", opt = true}
-        use {"ChristianChiarulli/dashboard-nvim", opt = true}
-        use {"windwp/nvim-autopairs", opt = true}
-        use {"terrortylor/nvim-comment", opt = true}
-        use {"kevinhwang91/nvim-bqf", opt = true}
-
-        -- Color
-        use {"christianchiarulli/nvcode-color-schemes.vim", opt = true}
-
-        -- Icons
-        use {"kyazdani42/nvim-web-devicons", opt = true}
-
-        -- Status Line and Bufferline
-        use {"glepnir/galaxyline.nvim", opt = true}
-        use {"romgrk/barbar.nvim", opt = true}
-
-        require_plugin("nvim-lspconfig")
-        require_plugin("lspsaga.nvim")
-        require_plugin("nvim-lspinstall")
-        require_plugin("friendly-snippets")
-        require_plugin("popup.nvim")
-        require_plugin("plenary.nvim")
-        require_plugin("telescope.nvim")
-        require_plugin("nvim-dap")
-        require_plugin("nvim-compe")
-        require_plugin("vim-vsnip")
-        require_plugin("nvim-treesitter")
-        require_plugin("nvim-ts-autotag")
-        require_plugin("nvim-tree.lua")
-        require_plugin("gitsigns.nvim")
-        require_plugin("which-key.nvim")
-        require_plugin("dashboard-nvim")
-        require_plugin("nvim-autopairs")
-        require_plugin("nvim-comment")
-        require_plugin("nvim-bqf")
-        require_plugin("nvcode-color-schemes.vim")
-        require_plugin("nvim-web-devicons")
-        require_plugin("galaxyline.nvim")
-        require_plugin("barbar.nvim")
+return require("packer").startup(function(use)
+    -- Packer can manage itself as an optional plugin
+    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", opt = true}
+    use {"glepnir/lspsaga.nvim", opt = true}
+    use {"kabouzeid/nvim-lspinstall", opt = true}
+    use {"folke/trouble.nvim", opt = true}
+
+    -- Telescope
+    use {"nvim-lua/popup.nvim", opt = true}
+    use {"nvim-lua/plenary.nvim", opt = true}
+    use {"nvim-telescope/telescope.nvim", opt = true}
+    use {"nvim-telescope/telescope-fzy-native.nvim", opt = true}
+    use {"nvim-telescope/telescope-project.nvim", opt = true}
+
+    -- Debugging
+    use {"mfussenegger/nvim-dap", opt = true}
+
+    -- Autocomplete
+    use {"hrsh7th/nvim-compe", opt = true}
+    use {"hrsh7th/vim-vsnip", opt = true}
+    use {"rafamadriz/friendly-snippets", opt = true}
+
+    -- Treesitter
+    use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
+    use {"windwp/nvim-ts-autotag", opt = true}
+    use {'andymass/vim-matchup', opt = true}
+
+    -- Explorer
+    use {"kyazdani42/nvim-tree.lua", opt = true}
+    use {"ahmedkhalf/lsp-rooter.nvim", opt = true} -- with this nvim-tree will follow you
+    -- TODO remove when open on dir is supported by nvimtree
+    use "kevinhwang91/rnvimr"
+
+    -- use {'lukas-reineke/indent-blankline.nvim', opt=true, branch = 'lua'}
+    use {"lewis6991/gitsigns.nvim", opt = true}
+    use {'f-person/git-blame.nvim', opt = true}
+    use {"folke/which-key.nvim", opt = true}
+    use {"ChristianChiarulli/dashboard-nvim", opt = true}
+    use {"windwp/nvim-autopairs", opt = true}
+    use {"kevinhwang91/nvim-bqf", opt = true}
+
+    -- Comments
+    use {"terrortylor/nvim-comment", opt = true}
+    use {'JoosepAlviste/nvim-ts-context-commentstring', opt = true}
+
+    -- Color
+    use {"christianchiarulli/nvcode-color-schemes.vim", opt = true}
+
+    -- Icons
+    use {"kyazdani42/nvim-web-devicons", opt = true}
+
+    -- Status Line and Bufferline
+    use {"glepnir/galaxyline.nvim", opt = true}
+    use {"romgrk/barbar.nvim", opt = true}
+
+    -- Zen Mode
+    use {"Pocco81/TrueZen.nvim", opt = true}
+
+    require_plugin("nvim-lspconfig")
+    require_plugin("lspsaga.nvim")
+    require_plugin("nvim-lspinstall")
+    require_plugin('trouble.nvim')
+    require_plugin("friendly-snippets")
+    require_plugin("popup.nvim")
+    require_plugin("plenary.nvim")
+    require_plugin("telescope.nvim")
+    require_plugin('telescope-project.nvim')
+    require_plugin("nvim-dap")
+    require_plugin("nvim-compe")
+    require_plugin("vim-vsnip")
+    require_plugin("nvim-treesitter")
+    require_plugin("nvim-ts-autotag")
+    require_plugin('vim-matchup')
+    require_plugin("nvim-tree.lua")
+    require_plugin("gitsigns.nvim")
+    require_plugin("git-blame.nvim")
+    require_plugin("which-key.nvim")
+    require_plugin("dashboard-nvim")
+    require_plugin("nvim-autopairs")
+    require_plugin("nvim-comment")
+    require_plugin("nvim-bqf")
+    require_plugin("nvcode-color-schemes.vim")
+    require_plugin("nvim-web-devicons")
+    require_plugin("galaxyline.nvim")
+    require_plugin("barbar.nvim")
+    require_plugin('lsp-rooter.nvim')
+    require_plugin("TrueZen.nvim")
+    require_plugin("nvim-ts-context-commentstring")
+
+    -- Extras
+    if O.extras then
+        use {'metakirby5/codi.vim', opt = true}
+        require_plugin('codi.vim')
+        use {'iamcco/markdown-preview.nvim', run = 'cd app && npm install', opt = true}
+        require_plugin('markdown-preview.nvim')
+        use {'numToStr/FTerm.nvim', opt = true}
+        require_plugin('numToStr/FTerm.nvim')
+        use {'monaqa/dial.nvim', opt = true}
+        require_plugin('dial.nvim')
+        use {'nacro90/numb.nvim', opt = true}
+        require_plugin('numb.nvim')
+        use {'turbio/bracey.vim', opt = true}
+        require_plugin('bracey.vim')
+        use {'phaazon/hop.nvim', opt = true}
+        require_plugin('hop.nvim')
+        use {'norcalli/nvim-colorizer.lua', opt = true}
+        require_plugin('nvim-colorizer.lua')
+        use {'windwp/nvim-spectre', opt = true}
+        require_plugin('windwp/nvim-spectre')
+        -- folke/todo-comments.nvim
+        -- gennaro-tedesco/nvim-jqx
+        -- TimUntersberger/neogit
+        -- folke/lsp-colors.nvim
+        -- simrat39/symbols-outline.nvim
+
+        -- Git
+        -- use {'tpope/vim-fugitive', opt = true}
+        -- use {'tpope/vim-rhubarb', opt = true}
+        -- pwntester/octo.nvim
+
+        -- Easily Create Gists
+        -- use {'mattn/vim-gist', opt = true}
+        -- use {'mattn/webapi-vim', opt = true}
     end
-)
+
+end)

+ 1 - 0
lv-settings.lua

@@ -14,6 +14,7 @@ O.auto_close_tree = 0
 O.wrap_lines = false
 O.timeoutlen = 100
 O.document_highlight = true
+O.extras = true
 
 -- dashboard
 -- O.dashboard.custom_header = {""}