فهرست منبع

Merge branch 'master' of github.com:ChristianChiarulli/LunarVim into stable

christianchiarulli 4 سال پیش
والد
کامیت
ec91300442

+ 9 - 2
lua/default-config.lua

@@ -78,7 +78,6 @@ O = {
     symbol_outline = { active = false },
     debug = { active = false },
     dap_install = { active = false },
-    lazygit = { active = false },
     lush = { active = false },
     diffview = { active = false },
     floatterm = { active = false },
@@ -86,7 +85,9 @@ O = {
     sanegx = { active = false },
   },
 
-  custom_plugins = {
+  user_which_key = {},
+
+  user_plugins = {
     -- use lv-config.lua for this not put here
   },
 
@@ -191,7 +192,13 @@ O = {
       },
     },
     svelte = {},
+
     php = {
+      format = {
+        format = {
+          default = "psr12",
+        },
+      },
       environment = {
         php_version = "7.4",
       },

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

@@ -1,6 +1,10 @@
 -- if not package.loaded['nvim-autopairs'] then
 --   return
 -- end
+local status_ok, autopairs = pcall(require, "nvim-autopairs")
+if not status_ok then
+  return
+end
 local npairs = require "nvim-autopairs"
 local Rule = require "nvim-autopairs.rule"
 

+ 5 - 1
lua/lv-colorizer/init.lua

@@ -1,4 +1,8 @@
-require("colorizer").setup({ "*" }, {
+local status_ok, colorizer = pcall(require, "colorizer")
+if not status_ok then
+  return
+end
+colorizer.setup({ "*" }, {
   RGB = true, -- #RGB hex codes
   RRGGBB = true, -- #RRGGBB hex codes
   RRGGBBAA = true, -- #RRGGBBAA hex codes

+ 7 - 3
lua/lv-compe/init.lua

@@ -7,7 +7,7 @@ local M = {}
 vim.g.vsnip_snippet_dir = O.vnsip_dir
 
 M.config = function()
-  opt = {
+  local opt = {
     enabled = O.auto_complete,
     autocomplete = true,
     debug = false,
@@ -39,8 +39,12 @@ M.config = function()
       -- for emoji press : (idk if that in compe tho)
     },
   }
+  local status_ok, compe = pcall(require, "compe")
+  if not status_ok then
+    return
+  end
 
-  require("compe").setup(opt)
+  compe.setup(opt)
 
   local t = function(str)
     return vim.api.nvim_replace_termcodes(str, true, true, true)
@@ -86,7 +90,7 @@ M.config = function()
   vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
 
   vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true })
-  -- vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true })
+  vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true })
   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 })

+ 45 - 0
lua/lv-floatterm/init.lua

@@ -0,0 +1,45 @@
+local M = {}
+
+M.config = function()
+  local status_ok, fterm = pcall(require, "FTerm")
+  if not status_ok then
+    return
+  end
+
+  fterm.setup {
+    dimensions = {
+      height = 0.8,
+      width = 0.8,
+      x = 0.5,
+      y = 0.5,
+    },
+    border = "single", -- or 'double'
+  }
+
+  -- Create LazyGit Terminal
+  local term = require "FTerm.terminal"
+  local lazy = term:new():setup {
+    cmd = "lazygit",
+    dimensions = {
+      height = 0.9,
+      width = 0.9,
+      x = 0.5,
+      y = 0.3,
+    },
+  }
+
+  local function is_installed(exe)
+    return vim.fn.executable(exe) == 1
+  end
+
+  -- Use this to toggle gitui in a floating terminal
+  function _G.__fterm_lazygit()
+    if is_installed "lazygit" ~= true then
+      print "Please install lazygit. Check documentation for more information"
+      return
+    end
+    lazy:toggle()
+  end
+end
+
+return M

+ 4 - 2
lua/lv-galaxyline/init.lua

@@ -1,8 +1,10 @@
 -- if not package.loaded['galaxyline'] then
 --   return
 -- end
-
-local gl = require "galaxyline"
+local status_ok, gl = pcall(require, "galaxyline")
+if not status_ok then
+  return
+end
 -- get my theme in galaxyline repo
 -- local colors = require('galaxyline.theme').default
 local colors = {

+ 5 - 1
lua/lv-gitsigns/init.lua

@@ -1,7 +1,11 @@
 local M = {}
 
 M.config = function()
-  require("gitsigns").setup {
+  local status_ok, gitsigns = pcall(require, "gitsigns ")
+  if not status_ok then
+    return
+  end
+  gitsigns.setup {
     signs = {
       -- TODO add hl to colorscheme
       add = {

+ 2 - 2
lua/lv-lspinstall/init.lua

@@ -1,7 +1,7 @@
 -- 1. get the config for this server from nvim-lspconfig and adjust the cmd path.
 --    relative paths are allowed, lspinstall automatically adjusts the cmd and cmd_cwd for us!
-local config = require("lspconfig").jdtls.document_config
-require("lspconfig/configs").jdtls = nil -- important, unset the loaded config again
+-- local config = require("lspconfig").jdtls.document_config
+-- require("lspconfig/configs").jdtls = nil -- important, unset the loaded config again
 -- config.default_config.cmd[1] = "./node_modules/.bin/bash-language-server"
 
 -- 2. extend the config with an install_script and (optionally) uninstall_script

+ 5 - 1
lua/lv-nvimtree/init.lua

@@ -3,6 +3,10 @@
 --end
 
 local M = {}
+local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
+if not status_ok then
+  return
+end
 
 M.config = function()
   local g = vim.g
@@ -52,7 +56,7 @@ M.config = function()
       symlink = "",
     },
   }
-  local tree_cb = require("nvim-tree.config").nvim_tree_callback
+  local tree_cb = nvim_tree_config.nvim_tree_callback
 
   vim.g.nvim_tree_bindings = {
     { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },

+ 5 - 1
lua/lv-telescope/init.lua

@@ -1,3 +1,7 @@
+local status_ok, telescope = pcall(require, "telescope")
+if not status_ok then
+  return
+end
 local actions = require "telescope.actions"
 -- if O.plugin.trouble.active then
 --     local trouble = require("trouble.providers.telescope")
@@ -5,7 +9,7 @@ local actions = require "telescope.actions"
 -- Global remapping
 ------------------------------
 -- '--color=never',
-require("telescope").setup {
+telescope.setup {
   defaults = {
     find_command = {
       "rg",

+ 5 - 1
lua/lv-treesitter/init.lua

@@ -80,8 +80,12 @@ if status then
   wk.register(textobj_move_keymaps["goto_previous_start"], normal)
   wk.register(textobj_move_keymaps["goto_previous_end"], normal)
 end
+local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
+if not status_ok then
+  return
+end
 
-require("nvim-treesitter.configs").setup {
+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 = {

+ 10 - 2
lua/lv-utils/init.lua

@@ -1,5 +1,12 @@
 local lv_utils = {}
 
+function lv_utils.reload_lv_config()
+  vim.cmd "source ~/.config/nvim/lv-config.lua"
+  vim.cmd "source ~/.config/nvim/lua/plugins.lua"
+  vim.cmd ":PackerCompile"
+  vim.cmd ":PackerInstall"
+end
+
 function lv_utils.define_augroups(definitions) -- {{{1
   -- Create autocommand groups based on the passed definitions
   --
@@ -24,7 +31,7 @@ end
 
 lv_utils.define_augroups {
 
-    _user_autocommands = O.user_autocommands,
+  _user_autocommands = O.user_autocommands,
   _general_settings = {
     {
       "TextYankPost",
@@ -46,6 +53,7 @@ lv_utils.define_augroups {
       "*",
       "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
     },
+    { "BufWritePost", "lv-config.lua", "lua require('lv-utils').reload_lv_config()" },
     { "VimLeavePre", "*", "set title set titleold=" },
   },
   -- _solidity = {
@@ -65,7 +73,7 @@ lv_utils.define_augroups {
   },
   _auto_resize = {
     -- will cause split windows to be resized evenly if main window is resized
-    {'VimResized ', '*', 'wincmd ='},
+    { "VimResized ", "*", "wincmd =" },
   },
   -- _mode_switching = {
   --   -- will switch between absolute and relative line numbers depending on mode

+ 32 - 31
lua/lv-which-key/init.lua

@@ -1,8 +1,12 @@
 -- if not package.loaded['which-key'] then
 --  return
 -- end
+local status_ok, which_key = pcall(require, "which-key")
+if not status_ok then
+  return
+end
 
-require("which-key").setup {
+which_key.setup {
   plugins = {
     marks = true, -- shows a list of your marks on ' and `
     registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
@@ -61,16 +65,12 @@ vim.api.nvim_set_keymap("n", "<Leader>h", ':let @/=""<CR>', { noremap = true, si
 
 -- explorer
 
--- TODO this introduces some bugs unfortunately
 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})
 
 vim.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>", { noremap = true, silent = true })
 
@@ -84,8 +84,6 @@ 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 })
 
--- TODO create entire treesitter section
-
 local mappings = {
 
   ["/"] = "Comment",
@@ -120,30 +118,10 @@ local mappings = {
     name = "Packer",
     c = { "<cmd>PackerCompile<cr>", "Compile" },
     i = { "<cmd>PackerInstall<cr>", "Install" },
-    r = { ":luafile %<cr>", "Reload" },
+    r = { "<cmd>lua require('lv-utils').reload_lv_config()<cr>", "Reload" },
     s = { "<cmd>PackerSync<cr>", "Sync" },
     u = { "<cmd>PackerUpdate<cr>", "Update" },
   },
-  -- diagnostics vanilla nvim
-  -- -- diagnostic
-  -- function lv_utils.get_all()
-  --     vim.lsp.diagnostic.get_all()
-  -- end
-  -- function lv_utils.get_next()
-  --     vim.lsp.diagnostic.get_next()
-  -- end
-  -- function lv_utils.get_prev()
-  --     vim.lsp.diagnostic.get_prev()
-  -- end
-  -- function lv_utils.goto_next()
-  --     vim.lsp.diagnostic.goto_next()
-  -- end
-  -- function lv_utils.goto_prev()
-  --     vim.lsp.diagnostic.goto_prev()
-  -- end
-  -- function lv_utils.show_line_diagnostics()
-  --     vim.lsp.diagnostic.show_line_diagnostics()
-  -- end
 
   -- " Available Debug Adapters:
   -- "   https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
@@ -200,7 +178,7 @@ local mappings = {
       "<cmd>Telescope lsp_workspace_diagnostics<cr>",
       "Workspace Diagnostics",
     },
-    f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" },
+    f = { "<cmd>Neoformat<cr>", "Format" },
     i = { "<cmd>LspInfo<cr>", "Info" },
     j = { "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<cr>", "Next Diagnostic" },
     k = { "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<cr>", "Prev Diagnostic" },
@@ -263,8 +241,22 @@ if O.plugin.zen.active then
   vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", { noremap = true, silent = true })
   mappings["z"] = "Zen"
 end
-if O.plugin.lazygit.active then
-  vim.api.nvim_set_keymap("n", "<leader>gg", ":LazyGit<CR>", { noremap = true, silent = true })
+if O.plugin.floatterm.active then
+  vim.api.nvim_set_keymap("n", "<leader>gg", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true })
+  vim.api.nvim_set_keymap("n", "<A-i>", "<CMD>lua require('FTerm').toggle()<CR>", { noremap = true, silent = true })
+  vim.api.nvim_set_keymap(
+    "t",
+    "<A-i>",
+    "<C-\\><C-n><CMD>lua require('FTerm').toggle()<CR>",
+    { noremap = true, silent = true }
+  )
+  vim.api.nvim_set_keymap("n", "<A-l>", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true })
+  vim.api.nvim_set_keymap(
+    "t",
+    "<A-l>",
+    "<C-\\><C-n><CMD>lua _G.__fterm_lazygit()<CR>",
+    { noremap = true, silent = true }
+  )
   mappings["gg"] = "LazyGit"
 end
 if O.plugin.telescope_project.active then
@@ -302,5 +294,14 @@ if O.lushmode then
   }
 end
 
+-- for _, v in pairs(O.user_which_key) do
+-- end
+for k, v in pairs(O.user_which_key) do
+  mappings[k] = v
+  -- table.insert(mappings, O.user_which_key[1])
+  -- print(k)
+  --   print(v)
+end
+
 local wk = require "which-key"
 wk.register(mappings, opts)

+ 5 - 1
lua/lv-zen/init.lua

@@ -1,7 +1,11 @@
 local M = {}
+local status_ok, zen_mode = pcall(require, "zen-mode")
+if not status_ok then
+  return
+end
 
 M.config = function()
-  require("zen-mode").setup {
+  zen_mode.setup {
     window = {
       backdrop = 1,
       height = 0.85, -- height of the Zen window

+ 19 - 19
lua/plugins.lua

@@ -94,7 +94,11 @@ return require("packer").startup(function(use)
     "terrortylor/nvim-comment",
     cmd = "CommentToggle",
     config = function()
-      require("nvim_comment").setup()
+      local status_ok, nvim_comment = pcall(require, "nvim_comment")
+      if not status_ok then
+        return
+      end
+      nvim_comment.setup()
     end,
   }
 
@@ -145,8 +149,8 @@ return require("packer").startup(function(use)
     "norcalli/nvim-colorizer.lua",
     event = "BufRead",
     config = function()
-      require("colorizer").setup()
-      vim.cmd "ColorizerReloadAllBuffers"
+      require "lv-colorizer"
+      -- vim.cmd "ColorizerReloadAllBuffers"
     end,
     disable = not O.plugin.colorizer.active,
   }
@@ -202,14 +206,18 @@ return require("packer").startup(function(use)
   use {
     "mfussenegger/nvim-dap",
     config = function()
-      require "dap"
+      local status_ok, dap = pcall(require, "dap")
+      if not status_ok then
+        return
+      end
+      -- require "dap"
       vim.fn.sign_define("DapBreakpoint", {
         text = "",
         texthl = "LspDiagnosticsSignError",
         linehl = "",
         numhl = "",
       })
-      require("dap").defaults.fallback.terminal_win_cmd = "50vsplit new"
+      dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
     end,
     disable = not O.plugin.debug.active,
   }
@@ -217,12 +225,9 @@ return require("packer").startup(function(use)
   -- Floating terminal
   use {
     "numToStr/FTerm.nvim",
-    event = "BufRead",
+    event = "BufWinEnter",
     config = function()
-      require("FTerm").setup {
-        dimensions = { height = 0.8, width = 0.8, x = 0.5, y = 0.5 },
-        border = "single", -- or 'double'
-      }
+      require("lv-floatterm").config()
     end,
     disable = not O.plugin.floatterm.active,
   }
@@ -238,7 +243,9 @@ return require("packer").startup(function(use)
   use {
     "nvim-telescope/telescope-project.nvim",
     event = "BufRead",
-    setup = function () vim.cmd[[packadd telescope.nvim]] end,
+    setup = function()
+      vim.cmd [[packadd telescope.nvim]]
+    end,
     disable = not O.plugin.telescope_project.active,
   }
 
@@ -249,13 +256,6 @@ return require("packer").startup(function(use)
     disable = not O.plugin.sanegx.active,
   }
 
-  -- Lazygit
-  use {
-    "kdheepak/lazygit.nvim",
-    cmd = "LazyGit",
-    disable = not O.plugin.lazygit.active,
-  }
-
   -- Diffview
   use {
     "sindrets/diffview.nvim",
@@ -355,7 +355,7 @@ return require("packer").startup(function(use)
     disable = not O.plugin.ts_hintobjects.active,
   }
 
-  for _, plugin in pairs(O.custom_plugins) do
+  for _, plugin in pairs(O.user_plugins) do
     packer.use(plugin)
   end
 end)

+ 13 - 28
utils/installer/lv-config.example.lua

@@ -5,7 +5,8 @@ Linters should be
 filled in as strings with either
 a global executable or a path to
 an executable
-]] -- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
+]]
+-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
 -- general
 O.format_on_save = true
 O.auto_complete = true
@@ -13,12 +14,9 @@ O.colorscheme = "spacegray"
 O.auto_close_tree = 0
 O.wrap_lines = false
 O.timeoutlen = 100
-O.document_highlight = true
 O.leader_key = " "
 O.ignore_case = true
 O.smart_case = true
-O.lushmode = false
-O.transparent_window = false
 
 -- TODO User Config for predefined plugins
 -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
@@ -34,42 +32,29 @@ O.plugin.zen.active = false
 
 -- if you don't want all the parsers change this to a table of the ones you want
 O.treesitter.ensure_installed = "all"
-O.treesitter.ignore_install = {"haskell"}
+O.treesitter.ignore_install = { "haskell" }
 O.treesitter.highlight.enabled = true
 
-O.lang.clang.diagnostics.virtual_text = true
-O.lang.clang.diagnostics.signs = true
-O.lang.clang.diagnostics.underline = true
-
 -- python
--- add things like O.python.linter.flake8.exec_path
 -- O.python.linter = 'flake8'
 O.lang.python.isort = true
 O.lang.python.diagnostics.virtual_text = true
-O.lang.python.diagnostics.signs = true
-O.lang.python.diagnostics.underline = true
-O.lang.python.analysis.type_checking = "off"
-O.lang.python.analysis.auto_search_paths = true
 O.lang.python.analysis.use_library_code_types = true
 
 -- javascript
 O.lang.tsserver.linter = nil
 
--- php
-O.lang.php.environment.php_version = "7.4"
-O.lang.php.diagnostics.signs = true
-O.lang.php.diagnostics.underline = true
-O.lang.php.filetypes = {"php", "phtml"}
-O.lang.php.format = {
-  format = {
-    default = "psr12"
-  }
-}
-
+-- Additional Plugins
+-- O.custom_plugins = {{"windwp/nvim-ts-autotag"}}
 
 -- Autocommands (https://neovim.io/doc/user/autocmd.html)
 -- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}}
 
--- Additional Plugins
--- O.custom_plugins = {{"windwp/nvim-ts-autotag"}}
-
+-- Additional Leader bindings for WhichKey
+-- O.user_which_key = {
+--   A = {
+--     name = "+Custom Leader Keys",
+--     a = { "<cmd>echo 'first custom command'<cr>", "Description for a" },
+--     b = { "<cmd>echo 'second custom command'<cr>", "Description for b" },
+--   },
+-- }