Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: neo-tree template integration #201

Closed
gpproton opened this issue Dec 20, 2024 · 6 comments · Fixed by #202
Closed

help: neo-tree template integration #201

gpproton opened this issue Dec 20, 2024 · 6 comments · Fixed by #202

Comments

@gpproton
Copy link

Hi i've been exploring the possibility of using easy-dotnet with neo-tree with no luck or understanding on getting it working, i've tried using the sample for nvim-tree as a refrence but there's no luck. I've checked the neo-tree docs and could not see any refrence to on_attach, any assistance would be appreciated on this.

    require("nvim-tree").setup({
      on_attach = function(bufnr)
        local api = require('nvim-tree.api')

        local function opts(desc)
          return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
        end

        vim.keymap.set('n', 'A', function()
          local node = api.tree.get_node_under_cursor()
          local path = node.type == "directory" and node.absolute_path or vim.fs.dirname(node.absolute_path)
          require("easy-dotnet").create_new_item(path)
        end, opts('Create file from dotnet template'))
      end
    })
@GustavEikaas
Copy link
Owner

GustavEikaas commented Dec 20, 2024

I havent used neo-tree personally but I could look into it. However you might consider changing to nvim-tree instead. They are very similiar. Neo-tree might not be maintained anymore unless they find a new maintainer

@GustavEikaas
Copy link
Owner

GustavEikaas commented Dec 20, 2024

Messed around for a bit and it is possible. I need to make a few changes in my code for the tree to automatically refresh after creating files but basically this code is all you need

If you have enabled the use_libuv_file_watcher. The tree is automatically refreshed and you can safely ignore the --BUG: comment

  {
    "nvim-neo-tree/neo-tree.nvim",
    branch = "v3.x",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
      "MunifTanjim/nui.nvim",
      -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
    },
    config = function()
      require("neo-tree").setup({
        filesystem = {
          use_libuv_file_watcher = true,
          window = {
            mappings = {
              ["R"] = "easy",
            },
          },
          commands = {
            ["easy"] = function(state)
              local node = state.tree:get_node()
              local path = node.type == "directory" and node.path or vim.fs.dirname(node.path)
              require("easy-dotnet").create_new_item(path)
              --BUG: Must wait for create_new_item to complete
              -- require("neo-tree.ui.renderer").redraw(state)
            end
          }
        },
      })

      vim.cmd([[nnoremap \ :Neotree reveal<cr>]])
    end
  }

Let me know if it works for you!

@GustavEikaas
Copy link
Owner

Will add to readme after resolving the refresh issue. I dont want to force users to use the file_watcher

@gpproton
Copy link
Author

I havent used neo-tree personally but I could look into it. However you might consider changing to nvim-tree instead. They are very similiar. Neo-tree might not be maintained anymore unless they find a new maintainer

I think someone else is taking over the mainenance since lot of neovim distribution use it.

@gpproton
Copy link
Author

Messed around for a bit and it is possible. I need to make a few changes in my code for the tree to automatically refresh after creating files but basically this code is all you need

If you have enabled the use_libuv_file_watcher. The tree is automatically refreshed and you can safely ignore the --BUG: comment

  {
    "nvim-neo-tree/neo-tree.nvim",
    branch = "v3.x",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
      "MunifTanjim/nui.nvim",
      -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
    },
    config = function()
      require("neo-tree").setup({
        filesystem = {
          use_libuv_file_watcher = true,
          window = {
            mappings = {
              ["R"] = "easy",
            },
          },
          commands = {
            ["easy"] = function(state)
              local node = state.tree:get_node()
              local path = node.type == "directory" and node.path or vim.fs.dirname(node.path)
              require("easy-dotnet").create_new_item(path)
              --BUG: Must wait for create_new_item to complete
              -- require("neo-tree.ui.renderer").redraw(state)
            end
          }
        },
      })

      vim.cmd([[nnoremap \ :Neotree reveal<cr>]])
    end
  }

Let me know if it works for you!

Thanks i'll be looking forward to the new version of easy-dotnet so i can start using, really appreciate the proactiveness it makes it easy to keep using neovim.

@GustavEikaas GustavEikaas linked a pull request Dec 21, 2024 that will close this issue
@GustavEikaas
Copy link
Owner

Done, code example added to readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants