diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/default-config.lua | 11 | ||||
| -rw-r--r-- | lua/lv-autopairs/init.lua | 4 | ||||
| -rw-r--r-- | lua/lv-colorizer/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-compe/init.lua | 10 | ||||
| -rw-r--r-- | lua/lv-floatterm/init.lua | 45 | ||||
| -rw-r--r-- | lua/lv-galaxyline/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-gitsigns/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-lspinstall/init.lua | 4 | ||||
| -rw-r--r-- | lua/lv-nvimtree/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-telescope/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-treesitter/init.lua | 6 | ||||
| -rw-r--r-- | lua/lv-utils/init.lua | 12 | ||||
| -rw-r--r-- | lua/lv-which-key/init.lua | 63 | ||||
| -rw-r--r-- | lua/lv-zen/init.lua | 6 | ||||
| -rw-r--r-- | lua/plugins.lua | 38 | 
15 files changed, 162 insertions, 67 deletions
| diff --git a/lua/default-config.lua b/lua/default-config.lua index fcf33799..9d785a4d 100644 --- a/lua/default-config.lua +++ b/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",        }, diff --git a/lua/lv-autopairs/init.lua b/lua/lv-autopairs/init.lua index 6a9e4286..b8dad5f3 100644 --- a/lua/lv-autopairs/init.lua +++ b/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" diff --git a/lua/lv-colorizer/init.lua b/lua/lv-colorizer/init.lua index ac5f1356..abe2f728 100644 --- a/lua/lv-colorizer/init.lua +++ b/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 diff --git a/lua/lv-compe/init.lua b/lua/lv-compe/init.lua index 5b86f27e..f42e8ad3 100644 --- a/lua/lv-compe/init.lua +++ b/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 }) diff --git a/lua/lv-floatterm/init.lua b/lua/lv-floatterm/init.lua new file mode 100644 index 00000000..dee11540 --- /dev/null +++ b/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 diff --git a/lua/lv-galaxyline/init.lua b/lua/lv-galaxyline/init.lua index 2189eab3..69404b48 100644 --- a/lua/lv-galaxyline/init.lua +++ b/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 = { diff --git a/lua/lv-gitsigns/init.lua b/lua/lv-gitsigns/init.lua index 7f1fbff4..d98e6281 100644 --- a/lua/lv-gitsigns/init.lua +++ b/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 = { diff --git a/lua/lv-lspinstall/init.lua b/lua/lv-lspinstall/init.lua index 68fcfa2b..f6796fe3 100644 --- a/lua/lv-lspinstall/init.lua +++ b/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 diff --git a/lua/lv-nvimtree/init.lua b/lua/lv-nvimtree/init.lua index 37a931ef..8f616730 100644 --- a/lua/lv-nvimtree/init.lua +++ b/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" }, diff --git a/lua/lv-telescope/init.lua b/lua/lv-telescope/init.lua index 6bbce291..8175a7ed 100644 --- a/lua/lv-telescope/init.lua +++ b/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", diff --git a/lua/lv-treesitter/init.lua b/lua/lv-treesitter/init.lua index 27877f03..8ec9b08a 100644 --- a/lua/lv-treesitter/init.lua +++ b/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 = { diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index db3deb87..656905f2 100644 --- a/lua/lv-utils/init.lua +++ b/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 diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 5fb3c92d..f36815b6 100644 --- a/lua/lv-which-key/init.lua +++ b/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) diff --git a/lua/lv-zen/init.lua b/lua/lv-zen/init.lua index 0d6bfca0..d4a3da5c 100644 --- a/lua/lv-zen/init.lua +++ b/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 diff --git a/lua/plugins.lua b/lua/plugins.lua index 69542b94..0c138d32 100644 --- a/lua/plugins.lua +++ b/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) | 
