diff --git a/.config/nvim/lua/josean/plugins-setup.lua b/.config/nvim/lua/josean/plugins-setup.lua index db50330..407b439 100644 --- a/.config/nvim/lua/josean/plugins-setup.lua +++ b/.config/nvim/lua/josean/plugins-setup.lua @@ -76,7 +76,14 @@ return packer.startup(function(use) -- configuring lsp servers use("neovim/nvim-lspconfig") -- easily configure language servers use("hrsh7th/cmp-nvim-lsp") -- for autocompletion - use({ "glepnir/lspsaga.nvim", branch = "main" }) -- enhanced lsp uis + use({ + "glepnir/lspsaga.nvim", + branch = "main", + requires = { + { "nvim-tree/nvim-web-devicons" }, + { "nvim-treesitter/nvim-treesitter" }, + }, + }) -- enhanced lsp uis use("jose-elias-alvarez/typescript.nvim") -- additional functionality for typescript server (e.g. rename file & update imports) use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion diff --git a/.config/nvim/lua/josean/plugins/nvim-tree.lua b/.config/nvim/lua/josean/plugins/nvim-tree.lua index fc60cf5..342b9b0 100644 --- a/.config/nvim/lua/josean/plugins/nvim-tree.lua +++ b/.config/nvim/lua/josean/plugins/nvim-tree.lua @@ -38,3 +38,27 @@ nvimtree.setup({ -- ignore = false, -- }, }) + +-- open nvim-tree on setup + +local function open_nvim_tree(data) + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + + if not no_name and not directory then + return + end + + -- change to the directory + if directory then + vim.cmd.cd(data.file) + end + + -- open the tree + require("nvim-tree.api").tree.open() +end + +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })