copy selector in neotree
This commit is contained in:
		
							parent
							
								
									cd1cd5f116
								
							
						
					
					
						commit
						6a8f5a7446
					
				
							
								
								
									
										23
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										23
									
								
								init.lua
								
								
								
								
							| 
						 | 
				
			
			@ -578,7 +578,10 @@ require('lazy').setup({
 | 
			
		|||
        tsserver = {},
 | 
			
		||||
        angularls = {
 | 
			
		||||
          config = {
 | 
			
		||||
            root_dir = require('lspconfig.util').root_pattern('angular.json', 'project.json'),
 | 
			
		||||
            cwd = function()
 | 
			
		||||
              return require('lspconfig.util').root_pattern('angular.json', 'project.json')
 | 
			
		||||
            end,
 | 
			
		||||
            require_cwd = true,
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        -- css_variables = {},
 | 
			
		||||
| 
						 | 
				
			
			@ -797,24 +800,6 @@ require('lazy').setup({
 | 
			
		|||
    end,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- You can easily change to a different colorscheme.
 | 
			
		||||
    -- Change the name of the colorscheme plugin below, and then
 | 
			
		||||
    -- change the command in the config to whatever the name of that colorscheme is.
 | 
			
		||||
    --
 | 
			
		||||
    -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
 | 
			
		||||
    'folke/tokyonight.nvim',
 | 
			
		||||
    priority = 1000, -- Make sure to load this before all the other start plugins.
 | 
			
		||||
    init = function()
 | 
			
		||||
      -- Load the colorscheme here.
 | 
			
		||||
      -- Like many other themes, this one has different styles, and you could load
 | 
			
		||||
      -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
 | 
			
		||||
      vim.cmd.colorscheme 'tokyonight-night'
 | 
			
		||||
 | 
			
		||||
      -- You can configure highlights by doing something like:
 | 
			
		||||
      vim.cmd.hi 'Comment gui=none'
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  -- Highlight todo, notes, etc in comments
 | 
			
		||||
  { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,9 +15,49 @@ return {
 | 
			
		|||
  },
 | 
			
		||||
  opts = {
 | 
			
		||||
    filesystem = {
 | 
			
		||||
      commands = {
 | 
			
		||||
        copy_selector = function(state)
 | 
			
		||||
          local node = state.tree:get_node()
 | 
			
		||||
          local filepath = node:get_id()
 | 
			
		||||
          local filename = node.name
 | 
			
		||||
          local modify = vim.fn.fnamemodify
 | 
			
		||||
 | 
			
		||||
          local vals = {
 | 
			
		||||
            ['BASENAME'] = modify(filename, ':r'),
 | 
			
		||||
            ['EXTENSION'] = modify(filename, ':e'),
 | 
			
		||||
            ['FILENAME'] = filename,
 | 
			
		||||
            ['PATH (CWD)'] = modify(filepath, ':.'),
 | 
			
		||||
            ['PATH (HOME)'] = modify(filepath, ':~'),
 | 
			
		||||
            ['PATH'] = filepath,
 | 
			
		||||
            ['URI'] = vim.uri_from_fname(filepath),
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          local options = vim.tbl_filter(function(val)
 | 
			
		||||
            return vals[val] ~= ''
 | 
			
		||||
          end, vim.tbl_keys(vals))
 | 
			
		||||
          if vim.tbl_isempty(options) then
 | 
			
		||||
            vim.notify('No values to copy', vim.log.levels.WARN)
 | 
			
		||||
            return
 | 
			
		||||
          end
 | 
			
		||||
          table.sort(options)
 | 
			
		||||
          vim.ui.select(options, {
 | 
			
		||||
            prompt = 'Choose to copy to clipboard:',
 | 
			
		||||
            format_item = function(item)
 | 
			
		||||
              return ('%s: %s'):format(item, vals[item])
 | 
			
		||||
            end,
 | 
			
		||||
          }, function(choice)
 | 
			
		||||
            local result = vals[choice]
 | 
			
		||||
            if result then
 | 
			
		||||
              vim.notify(('Copied: `%s`'):format(result))
 | 
			
		||||
              vim.fn.setreg('+', result)
 | 
			
		||||
            end
 | 
			
		||||
          end)
 | 
			
		||||
        end,
 | 
			
		||||
      },
 | 
			
		||||
      window = {
 | 
			
		||||
        mappings = {
 | 
			
		||||
          ['\\'] = 'close_window',
 | 
			
		||||
          ['Y'] = 'copy_selector',
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue