add custom config for net-tree
This commit is contained in:
		
							parent
							
								
									95653c6526
								
							
						
					
					
						commit
						c516919105
					
				| 
						 | 
					@ -0,0 +1,60 @@
 | 
				
			||||||
 | 
					return {
 | 
				
			||||||
 | 
					  ActiveLSP = '',
 | 
				
			||||||
 | 
					  ActiveTS = '',
 | 
				
			||||||
 | 
					  ArrowLeft = '',
 | 
				
			||||||
 | 
					  ArrowRight = '',
 | 
				
			||||||
 | 
					  Bookmarks = '',
 | 
				
			||||||
 | 
					  BufferClose = '',
 | 
				
			||||||
 | 
					  DapBreakpoint = '',
 | 
				
			||||||
 | 
					  DapBreakpointCondition = '',
 | 
				
			||||||
 | 
					  DapBreakpointRejected = '',
 | 
				
			||||||
 | 
					  DapLogPoint = '.>',
 | 
				
			||||||
 | 
					  DapStopped = '',
 | 
				
			||||||
 | 
					  Debugger = '',
 | 
				
			||||||
 | 
					  DefaultFile = '',
 | 
				
			||||||
 | 
					  Diagnostic = '',
 | 
				
			||||||
 | 
					  DiagnosticError = '',
 | 
				
			||||||
 | 
					  DiagnosticHint = '',
 | 
				
			||||||
 | 
					  DiagnosticInfo = '',
 | 
				
			||||||
 | 
					  DiagnosticWarn = '',
 | 
				
			||||||
 | 
					  Ellipsis = '…',
 | 
				
			||||||
 | 
					  FileNew = '',
 | 
				
			||||||
 | 
					  FileModified = '',
 | 
				
			||||||
 | 
					  FileReadOnly = '',
 | 
				
			||||||
 | 
					  FoldClosed = '',
 | 
				
			||||||
 | 
					  FoldOpened = '',
 | 
				
			||||||
 | 
					  FoldSeparator = ' ',
 | 
				
			||||||
 | 
					  FolderClosed = '',
 | 
				
			||||||
 | 
					  FolderEmpty = '',
 | 
				
			||||||
 | 
					  FolderOpen = '',
 | 
				
			||||||
 | 
					  Git = '',
 | 
				
			||||||
 | 
					  GitAdd = '',
 | 
				
			||||||
 | 
					  GitBranch = '',
 | 
				
			||||||
 | 
					  GitChange = '',
 | 
				
			||||||
 | 
					  GitConflict = '',
 | 
				
			||||||
 | 
					  GitDelete = '',
 | 
				
			||||||
 | 
					  GitIgnored = '◌',
 | 
				
			||||||
 | 
					  GitRenamed = '➜',
 | 
				
			||||||
 | 
					  GitSign = '▎',
 | 
				
			||||||
 | 
					  GitStaged = '✓',
 | 
				
			||||||
 | 
					  GitUnstaged = '✗',
 | 
				
			||||||
 | 
					  GitUntracked = '★',
 | 
				
			||||||
 | 
					  LSPLoaded = '', -- TODO: Remove unused icon in AstroNvim v4
 | 
				
			||||||
 | 
					  LSPLoading1 = '',
 | 
				
			||||||
 | 
					  LSPLoading2 = '',
 | 
				
			||||||
 | 
					  LSPLoading3 = '',
 | 
				
			||||||
 | 
					  MacroRecording = '',
 | 
				
			||||||
 | 
					  Package = '',
 | 
				
			||||||
 | 
					  Paste = '',
 | 
				
			||||||
 | 
					  Refresh = '',
 | 
				
			||||||
 | 
					  Search = '',
 | 
				
			||||||
 | 
					  Selected = '❯',
 | 
				
			||||||
 | 
					  Session = '',
 | 
				
			||||||
 | 
					  Sort = '',
 | 
				
			||||||
 | 
					  Spellcheck = '',
 | 
				
			||||||
 | 
					  Tab = '',
 | 
				
			||||||
 | 
					  TabClose = '',
 | 
				
			||||||
 | 
					  Terminal = '',
 | 
				
			||||||
 | 
					  Window = '',
 | 
				
			||||||
 | 
					  WordFile = '',
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,41 @@
 | 
				
			||||||
 | 
					return {
 | 
				
			||||||
 | 
					  ActiveLSP = 'LSP:',
 | 
				
			||||||
 | 
					  ArrowLeft = '<',
 | 
				
			||||||
 | 
					  ArrowRight = '>',
 | 
				
			||||||
 | 
					  BufferClose = 'x',
 | 
				
			||||||
 | 
					  DapBreakpoint = 'B',
 | 
				
			||||||
 | 
					  DapBreakpointCondition = 'C',
 | 
				
			||||||
 | 
					  DapBreakpointRejected = 'R',
 | 
				
			||||||
 | 
					  DapLogPoint = 'L',
 | 
				
			||||||
 | 
					  DapStopped = '>',
 | 
				
			||||||
 | 
					  DefaultFile = '[F]',
 | 
				
			||||||
 | 
					  DiagnosticError = 'X',
 | 
				
			||||||
 | 
					  DiagnosticHint = '?',
 | 
				
			||||||
 | 
					  DiagnosticInfo = 'i',
 | 
				
			||||||
 | 
					  DiagnosticWarn = '!',
 | 
				
			||||||
 | 
					  Ellipsis = '...',
 | 
				
			||||||
 | 
					  FileModified = '*',
 | 
				
			||||||
 | 
					  FileReadOnly = '[lock]',
 | 
				
			||||||
 | 
					  FoldClosed = '+',
 | 
				
			||||||
 | 
					  FoldOpened = '-',
 | 
				
			||||||
 | 
					  FoldSeparator = ' ',
 | 
				
			||||||
 | 
					  FolderClosed = '[D]',
 | 
				
			||||||
 | 
					  FolderEmpty = '[E]',
 | 
				
			||||||
 | 
					  FolderOpen = '[O]',
 | 
				
			||||||
 | 
					  GitAdd = '[+]',
 | 
				
			||||||
 | 
					  GitChange = '[/]',
 | 
				
			||||||
 | 
					  GitConflict = '[!]',
 | 
				
			||||||
 | 
					  GitDelete = '[-]',
 | 
				
			||||||
 | 
					  GitIgnored = '[I]',
 | 
				
			||||||
 | 
					  GitRenamed = '[R]',
 | 
				
			||||||
 | 
					  GitSign = '|',
 | 
				
			||||||
 | 
					  GitStaged = '[S]',
 | 
				
			||||||
 | 
					  GitUnstaged = '[U]',
 | 
				
			||||||
 | 
					  GitUntracked = '[?]',
 | 
				
			||||||
 | 
					  MacroRecording = 'Recording:',
 | 
				
			||||||
 | 
					  Paste = '[PASTE]',
 | 
				
			||||||
 | 
					  Search = '?',
 | 
				
			||||||
 | 
					  Selected = '*',
 | 
				
			||||||
 | 
					  Spellcheck = '[SPELL]',
 | 
				
			||||||
 | 
					  TabClose = 'X',
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -3,13 +3,12 @@
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
-- See the kickstart.nvim README for more information
 | 
					-- See the kickstart.nvim README for more information
 | 
				
			||||||
vim.opt.relativenumber = true
 | 
					vim.opt.relativenumber = true
 | 
				
			||||||
vim.g.have_nerd_font = false
 | 
					vim.g.have_nerd_font = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return {
 | 
					require('lazy').setup {
 | 
				
			||||||
  -- require 'kickstart.plugins.debug',
 | 
					 | 
				
			||||||
  require 'kickstart.plugins.indent_line',
 | 
					  require 'kickstart.plugins.indent_line',
 | 
				
			||||||
  -- require 'kickstart.plugins.lint',
 | 
					 | 
				
			||||||
  require 'kickstart.plugins.autopairs',
 | 
					  require 'kickstart.plugins.autopairs',
 | 
				
			||||||
  require 'kickstart.plugins.neo-tree',
 | 
					 | 
				
			||||||
  require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
 | 
					  require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,130 @@
 | 
				
			||||||
 | 
					-- Neo-tree is a Neovim plugin to browse the file system
 | 
				
			||||||
 | 
					-- https://github.com/nvim-neo-tree/neo-tree.nvim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local utils = require 'custom.utils'
 | 
				
			||||||
 | 
					local get_icon = utils.get_icon
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return {
 | 
				
			||||||
 | 
					  'nvim-neo-tree/neo-tree.nvim',
 | 
				
			||||||
 | 
					  version = '*',
 | 
				
			||||||
 | 
					  dependencies = {
 | 
				
			||||||
 | 
					    'nvim-lua/plenary.nvim',
 | 
				
			||||||
 | 
					    'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
 | 
				
			||||||
 | 
					    'MunifTanjim/nui.nvim',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  cmd = 'Neotree',
 | 
				
			||||||
 | 
					  keys = {
 | 
				
			||||||
 | 
					    { '\\', ':Neotree reveal<CR>', { desc = 'NeoTree reveal' } },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  opts = {
 | 
				
			||||||
 | 
					    close_if_last_window = true,
 | 
				
			||||||
 | 
					    sources = { 'filesystem', 'git_status' },
 | 
				
			||||||
 | 
					    source_selector = {
 | 
				
			||||||
 | 
					      winbar = true,
 | 
				
			||||||
 | 
					      content_layout = 'center',
 | 
				
			||||||
 | 
					      sources = {
 | 
				
			||||||
 | 
					        { source = 'filesystem', display_name = get_icon('FolderClosed', 1, true) .. 'File' },
 | 
				
			||||||
 | 
					        { source = 'git_status', display_name = get_icon('Git', 1, true) .. 'Git' },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    default_component_configs = {
 | 
				
			||||||
 | 
					      indent = { padding = 0 },
 | 
				
			||||||
 | 
					      icon = {
 | 
				
			||||||
 | 
					        folder_closed = get_icon 'FolderClosed',
 | 
				
			||||||
 | 
					        folder_open = get_icon 'FolderOpen',
 | 
				
			||||||
 | 
					        folder_empty = get_icon 'FolderEmpty',
 | 
				
			||||||
 | 
					        folder_empty_open = get_icon 'FolderEmpty',
 | 
				
			||||||
 | 
					        default = get_icon 'DefaultFile',
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      modified = { symbol = get_icon 'FileModified' },
 | 
				
			||||||
 | 
					      git_status = {
 | 
				
			||||||
 | 
					        symbols = {
 | 
				
			||||||
 | 
					          added = get_icon 'GitAdd',
 | 
				
			||||||
 | 
					          deleted = get_icon 'GitDelete',
 | 
				
			||||||
 | 
					          modified = get_icon 'GitChange',
 | 
				
			||||||
 | 
					          renamed = get_icon 'GitRenamed',
 | 
				
			||||||
 | 
					          untracked = get_icon 'GitUntracked',
 | 
				
			||||||
 | 
					          ignored = get_icon 'GitIgnored',
 | 
				
			||||||
 | 
					          unstaged = get_icon 'GitUnstaged',
 | 
				
			||||||
 | 
					          staged = get_icon 'GitStaged',
 | 
				
			||||||
 | 
					          conflict = get_icon 'GitConflict',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    commands = {
 | 
				
			||||||
 | 
					      parent_or_close = function(state)
 | 
				
			||||||
 | 
					        local node = state.tree:get_node()
 | 
				
			||||||
 | 
					        if (node.type == 'directory' or node:has_children()) and node:is_expanded() then
 | 
				
			||||||
 | 
					          state.commands.toggle_node(state)
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          require('neo-tree.ui.renderer').focus_node(state, node:get_parent_id())
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end,
 | 
				
			||||||
 | 
					      child_or_open = function(state)
 | 
				
			||||||
 | 
					        local node = state.tree:get_node()
 | 
				
			||||||
 | 
					        if node.type == 'directory' or node:has_children() then
 | 
				
			||||||
 | 
					          if not node:is_expanded() then -- if unexpanded, expand
 | 
				
			||||||
 | 
					            state.commands.toggle_node(state)
 | 
				
			||||||
 | 
					          else -- if expanded and has children, seleect the next child
 | 
				
			||||||
 | 
					            require('neo-tree.ui.renderer').focus_node(state, node:get_child_ids()[1])
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        else -- if not a directory just open it
 | 
				
			||||||
 | 
					          state.commands.open(state)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end,
 | 
				
			||||||
 | 
					      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
 | 
				
			||||||
 | 
					          utils.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
 | 
				
			||||||
 | 
					            utils.notify(('Copied: `%s`'):format(result))
 | 
				
			||||||
 | 
					            vim.fn.setreg('+', result)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end)
 | 
				
			||||||
 | 
					      end,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    window = {
 | 
				
			||||||
 | 
					      mappings = {
 | 
				
			||||||
 | 
					        ['[b'] = 'prev_source',
 | 
				
			||||||
 | 
					        [']b'] = 'next_source',
 | 
				
			||||||
 | 
					        Y = 'copy_selector',
 | 
				
			||||||
 | 
					        h = 'parent_or_close',
 | 
				
			||||||
 | 
					        l = 'child_or_open',
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    filesystem = {
 | 
				
			||||||
 | 
					      window = {
 | 
				
			||||||
 | 
					        mappings = {
 | 
				
			||||||
 | 
					          ['\\'] = 'close_window',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					local M = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M.notify(msg, type, opts)
 | 
				
			||||||
 | 
					  vim.schedule(function()
 | 
				
			||||||
 | 
					    vim.notify(msg, type, opts)
 | 
				
			||||||
 | 
					  end)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function M.get_icon(kind, padding, no_fallback)
 | 
				
			||||||
 | 
					  if not vim.g.have_nerd_font and no_fallback then
 | 
				
			||||||
 | 
					    return ''
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					  local icon_pack = vim.g.have_nerd_font and 'icons' or 'text_icons'
 | 
				
			||||||
 | 
					  if not M[icon_pack] then
 | 
				
			||||||
 | 
					    M.icons = require 'custom.icons.nerd_font'
 | 
				
			||||||
 | 
					    M.text_icons = require 'custom.icons.text'
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					  local icon = M[icon_pack] and M[icon_pack][kind]
 | 
				
			||||||
 | 
					  return icon and icon .. string.rep(' ', padding or 0) or ''
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return M
 | 
				
			||||||
		Loading…
	
		Reference in New Issue