diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/core/dashboard.lua | 11 | ||||
| -rw-r--r-- | lua/core/nvimtree.lua | 6 | ||||
| -rw-r--r-- | lua/core/project.lua | 48 | ||||
| -rw-r--r-- | lua/core/rooter.lua | 15 | ||||
| -rw-r--r-- | lua/core/telescope.lua | 3 | ||||
| -rw-r--r-- | lua/default-config.lua | 6 | ||||
| -rw-r--r-- | lua/lsp/init.lua | 9 | ||||
| -rw-r--r-- | lua/plugins.lua | 13 | 
8 files changed, 69 insertions, 42 deletions
| diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 649be14c..423cddd8 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -31,19 +31,16 @@ M.config = function()          description = { "  Find File          " },          command = "Telescope find_files",        }, -      b = { +      -- b is reserved for the core.project module +      c = {          description = { "  Recently Used Files" },          command = "Telescope oldfiles",        }, -      -- c = { -      --   description = { "  Load Last Session  " }, -      --   command = "SessionLoad", -      -- }, -      c = { +      d = {          description = { "  Find Word          " },          command = "Telescope live_grep",        }, -      d = { +      e = {          description = { "  Settings           " },          command = ":e " .. USER_CONFIG_PATH,        }, diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 7c99a91e..737f248e 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -60,6 +60,12 @@ M.setup = function()      g["nvim_tree_" .. opt] = val    end +  -- Implicitly update nvim-tree when project module is active +  if lvim.builtin.project.active then +    vim.g.nvim_tree_update_cwd = 1 +    vim.g.nvim_tree_respect_buf_cwd = 1 +  end +    local tree_cb = nvim_tree_config.nvim_tree_callback    if not g.nvim_tree_bindings then diff --git a/lua/core/project.lua b/lua/core/project.lua new file mode 100644 index 00000000..650f2924 --- /dev/null +++ b/lua/core/project.lua @@ -0,0 +1,48 @@ +local M = {} +-- +function M.config() +  lvim.builtin.project = { +    --- This is on by default since it's currently the expected behavior. +    ---@usage set to false to disable project.nvim. +    active = true, + +    -- Manual mode doesn't automatically change your root directory, so you have +    -- the option to manually do so using `:ProjectRoot` command. +    manual_mode = false, + +    -- Methods of detecting the root directory. **"lsp"** uses the native neovim +    -- lsp, while **"pattern"** uses vim-rooter like glob pattern matching. Here +    -- order matters: if one is not detected, the other is used as fallback. You +    -- can also delete or rearangne the detection methods. +    detection_methods = { "lsp", "pattern" }, + +    -- All the patterns used to detect root dir, when **"pattern"** is in +    -- detection_methods +    patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + +    -- When set to false, you will get a message when project.nvim changes your +    -- directory. +    silent_chdir = true, +  } +end +-- +function M.setup() +  local settings = lvim.builtin.project + +  -- Table of lsp clients to ignore by name +  -- eg: { "efm", ... } +  settings["ignore_lsp"] = {} + +  -- Path where project.nvim will store the project history for use in +  -- telescope +  settings["datapath"] = CACHE_PATH + +  require("project_nvim").setup(settings) + +  lvim.builtin.dashboard.custom_section["b"] = { +    description = { "  Recent Projects    " }, +    command = "Telescope projects", +  } +end +-- +return M diff --git a/lua/core/rooter.lua b/lua/core/rooter.lua deleted file mode 100644 index 8ebdf7cc..00000000 --- a/lua/core/rooter.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} -function M.config() -  lvim.builtin.rooter = { -    --- This is on by default since it's currently the expected behavior. -    ---@usage set to false to disable vim-rooter. -    active = true, -    silent_chdir = 1, -    manual_only = 0, -  } -end -function M.setup() -  vim.g.rooter_silent_chdir = lvim.builtin.rooter.silent_chdir -  vim.g.rooter_manual_only = lvim.builtin.rooter.manual_only -end -return M diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index e72727a4..5d9263d7 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -119,6 +119,9 @@ function M.setup()      return    end    telescope.setup(lvim.builtin.telescope) +  if lvim.builtin.project.active then +    pcall(require("telescope").load_extension, "projects") +  end  end  return M diff --git a/lua/default-config.lua b/lua/default-config.lua index ed9b17d6..f381b0b6 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -26,7 +26,7 @@ lvim = {      gitsigns = {},      which_key = {},      comment = {}, -    rooter = {}, +    project = {},      galaxyline = {},      bufferline = {},      dap = {}, @@ -102,8 +102,6 @@ lvim = {      popup_border = "single",      on_attach_callback = nil,      on_init_callback = nil, -    ---@usage query the project directory from the language server and use it to set the CWD -    smart_cwd = true,      null_ls = {        setup = {},      }, @@ -1301,7 +1299,7 @@ require("core.terminal").config()  require("core.telescope").config()  require("core.treesitter").config()  require("core.nvimtree").config() -require("core.rooter").config() +require("core.project").config()  require("core.bufferline").config()  require("core.autopairs").config()  require("core.comment").config() diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 920aceb3..1a6ceda3 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -55,14 +55,6 @@ local function add_lsp_buffer_keybindings(bufnr)    wk.register(keys, { mode = "n", buffer = bufnr })  end -local function set_smart_cwd(client) -  local proj_dir = client.config.root_dir -  if lvim.lsp.smart_cwd and proj_dir ~= "/" then -    vim.api.nvim_set_current_dir(proj_dir) -    require("core.nvimtree").change_tree_dir(proj_dir) -  end -end -  function M.common_capabilities()    local capabilities = vim.lsp.protocol.make_client_capabilities()    capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -127,7 +119,6 @@ function M.common_on_attach(client, bufnr)    end    lsp_highlight_document(client)    add_lsp_buffer_keybindings(bufnr) -  set_smart_cwd(client)    require("lsp.null-ls").setup(vim.bo.filetype)  end diff --git a/lua/plugins.lua b/lua/plugins.lua index c9e7f3c2..1cf494bc 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -147,17 +147,16 @@ return {      disable = not lvim.builtin.comment.active,    }, -  -- vim-rooter +  -- project.nvim    { -    "airblade/vim-rooter", -    -- event = "BufReadPre", +    "ahmedkhalf/project.nvim",      config = function() -      require("core.rooter").setup() -      if lvim.builtin.rooter.on_config_done then -        lvim.builtin.rooter.on_config_done() +      require("core.project").setup() +      if lvim.builtin.project.on_config_done then +        lvim.builtin.project.on_config_done()        end      end, -    disable = not lvim.builtin.rooter.active, +    disable = not lvim.builtin.project.active,    },    -- Icons | 
