feat(nvim): added plugin to mason install
This commit is contained in:
		
							parent
							
								
									2926dfe869
								
							
						
					
					
						commit
						a4f0645ab8
					
				
							
								
								
									
										87
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										87
									
								
								init.lua
								
								
								
								
							| 
						 | 
					@ -93,6 +93,7 @@ require('lazy').setup({
 | 
				
			||||||
      -- Automatically install LSPs to stdpath for neovim
 | 
					      -- Automatically install LSPs to stdpath for neovim
 | 
				
			||||||
      { 'williamboman/mason.nvim',                  config = true },
 | 
					      { 'williamboman/mason.nvim',                  config = true },
 | 
				
			||||||
      'williamboman/mason-lspconfig.nvim',
 | 
					      'williamboman/mason-lspconfig.nvim',
 | 
				
			||||||
 | 
					      { "WhoIsSethDaniel/mason-tool-installer.nvim" },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      -- Useful status updates for LSP
 | 
					      -- Useful status updates for LSP
 | 
				
			||||||
      -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
 | 
					      -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
 | 
				
			||||||
| 
						 | 
					@ -332,7 +333,8 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
 | 
				
			||||||
-- See `:help nvim-treesitter`
 | 
					-- See `:help nvim-treesitter`
 | 
				
			||||||
require('nvim-treesitter.configs').setup {
 | 
					require('nvim-treesitter.configs').setup {
 | 
				
			||||||
  -- Add languages to be installed here that you want installed for treesitter
 | 
					  -- Add languages to be installed here that you want installed for treesitter
 | 
				
			||||||
  ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
 | 
					  ensure_installed = { 'bicep', 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc',
 | 
				
			||||||
 | 
					    'vim' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
 | 
					  -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
 | 
				
			||||||
  auto_install = false,
 | 
					  auto_install = false,
 | 
				
			||||||
| 
						 | 
					@ -456,10 +458,11 @@ end
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
--  If you want to override the default filetypes that your language server will attach to you can
 | 
					--  If you want to override the default filetypes that your language server will attach to you can
 | 
				
			||||||
--  define the property 'filetypes' to the map in question.
 | 
					--  define the property 'filetypes' to the map in question.
 | 
				
			||||||
 | 
					--  URL: https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md
 | 
				
			||||||
local servers = {
 | 
					local servers = {
 | 
				
			||||||
  ansiblels = {},
 | 
					  ansiblels = {},
 | 
				
			||||||
  azure_pipelines_ls = {},
 | 
					  azure_pipelines_ls = {},
 | 
				
			||||||
  bashls = {},
 | 
					  bashls = { auto_update = true },
 | 
				
			||||||
  bicep = {},
 | 
					  bicep = {},
 | 
				
			||||||
  clangd = {},
 | 
					  clangd = {},
 | 
				
			||||||
  dockerls = {},
 | 
					  dockerls = {},
 | 
				
			||||||
| 
						 | 
					@ -468,7 +471,6 @@ local servers = {
 | 
				
			||||||
  gopls = {},
 | 
					  gopls = {},
 | 
				
			||||||
  helm_ls = {},
 | 
					  helm_ls = {},
 | 
				
			||||||
  html = { filetypes = { 'html', 'twig', 'hbs' } },
 | 
					  html = { filetypes = { 'html', 'twig', 'hbs' } },
 | 
				
			||||||
  jedi_language_server = {},
 | 
					 | 
				
			||||||
  jqls = {},
 | 
					  jqls = {},
 | 
				
			||||||
  jsonls = {},
 | 
					  jsonls = {},
 | 
				
			||||||
  lua_ls = {
 | 
					  lua_ls = {
 | 
				
			||||||
| 
						 | 
					@ -478,16 +480,89 @@ local servers = {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  powershell_es = {},
 | 
					  powershell_es = {},
 | 
				
			||||||
  pylsp = {},
 | 
					  pyright = {
 | 
				
			||||||
  pyright = {},
 | 
					    python = {
 | 
				
			||||||
  ruff_lsp = {},
 | 
					      analysis = {
 | 
				
			||||||
 | 
					        autoSearchPaths = true,
 | 
				
			||||||
 | 
					        diagnosticMode = "workspace",
 | 
				
			||||||
 | 
					        useLibraryCodeForTypes = true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  rust_analyzer = {},
 | 
					  rust_analyzer = {},
 | 
				
			||||||
 | 
					  sourcery = {
 | 
				
			||||||
 | 
					    init_options = {
 | 
				
			||||||
 | 
					      --- The Sourcery token for authenticating the user.
 | 
				
			||||||
 | 
					      --- This is retrieved from the Sourcery website and must be
 | 
				
			||||||
 | 
					      --- provided by each user. The extension must provide a
 | 
				
			||||||
 | 
					      --- configuration option for the user to provide this value.
 | 
				
			||||||
 | 
					      token = io.popen("pass sourcery/token", "r"):read("l"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      --- The extension's name and version as defined by the extension.
 | 
				
			||||||
 | 
					      extension_version = 'vim.lsp',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      --- The editor's name and version as defined by the editor.
 | 
				
			||||||
 | 
					      editor_version = 'vim',
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  terraformls = { filetypes = { 'tf' } },
 | 
					  terraformls = { filetypes = { 'tf' } },
 | 
				
			||||||
  tflint = { filetypes = { 'tf' } },
 | 
					  tflint = { filetypes = { 'tf' } },
 | 
				
			||||||
  tsserver = {},
 | 
					  tsserver = {},
 | 
				
			||||||
  yamlls = { filetypes = { 'tf' } },
 | 
					  yamlls = { filetypes = { 'tf' } },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Mason tool installer
 | 
				
			||||||
 | 
					local installed, MasonToolInstaller = pcall(require, "mason-tool-installer")
 | 
				
			||||||
 | 
					if not installed then
 | 
				
			||||||
 | 
					  vim.notify("Plugin 'mason-tool-installer' not installed ")
 | 
				
			||||||
 | 
					  return
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Mason Tool Installer
 | 
				
			||||||
 | 
					MasonToolInstaller.setup({
 | 
				
			||||||
 | 
					  -- a list of all tools you want to ensure are installed upon
 | 
				
			||||||
 | 
					  -- start; they should be the names Mason uses for each tool
 | 
				
			||||||
 | 
					  ensure_installed = {
 | 
				
			||||||
 | 
					    -- you can turn off/on auto_update per tool
 | 
				
			||||||
 | 
					    { "ansible-language-server",         auto_update = true },
 | 
				
			||||||
 | 
					    { "autopep8" },
 | 
				
			||||||
 | 
					    { "autopep8",                        auto_update = true },
 | 
				
			||||||
 | 
					    { "azure-pipelines-language-server", auto_update = true },
 | 
				
			||||||
 | 
					    { "bash-language-server",            auto_update = true },
 | 
				
			||||||
 | 
					    { "bicep-lsp",                       auto_update = true },
 | 
				
			||||||
 | 
					    { "black" },
 | 
				
			||||||
 | 
					    { "black",                           auto_update = true },
 | 
				
			||||||
 | 
					    { "css-lsp" },
 | 
				
			||||||
 | 
					    { "delve",                           auto_update = true },
 | 
				
			||||||
 | 
					    { "docker_compose_language_service", auto_update = true },
 | 
				
			||||||
 | 
					    { "dockerfile-language-server",      auto_update = true },
 | 
				
			||||||
 | 
					    { "editorconfig-checker" },
 | 
				
			||||||
 | 
					    { "helm-ls",                         auto_update = true },
 | 
				
			||||||
 | 
					    { "html-lsp" },
 | 
				
			||||||
 | 
					    { "html-lsp",                        auto_update = true },
 | 
				
			||||||
 | 
					    { "jason-lsp",                       auto_update = true },
 | 
				
			||||||
 | 
					    { "jq-lsp",                          auto_update = true },
 | 
				
			||||||
 | 
					    { "jsonls" },
 | 
				
			||||||
 | 
					    { "lua-language-server",             auto_update = true },
 | 
				
			||||||
 | 
					    { "powershell-editor-service",       auto_update = true },
 | 
				
			||||||
 | 
					    { "prettier" },
 | 
				
			||||||
 | 
					    { "pyright" },
 | 
				
			||||||
 | 
					    { "rust-analyzer" },
 | 
				
			||||||
 | 
					    { "sourcery",                        auto_update = true },
 | 
				
			||||||
 | 
					    { "stylua",                          auto_update = true },
 | 
				
			||||||
 | 
					    { "terraform-ls",                    auto_update = true },
 | 
				
			||||||
 | 
					    { "tflint",                          auto_update = true },
 | 
				
			||||||
 | 
					    { "vim-language-server",             auto_update = true },
 | 
				
			||||||
 | 
					    { "yaml-language-server",            auto_update = true },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  auto_update = false,
 | 
				
			||||||
 | 
					  run_on_start = true,
 | 
				
			||||||
 | 
					  start_delay = 3000, -- 3 second delay
 | 
				
			||||||
 | 
					  debounce_hours = 5, -- at least 5 hours between attempts to install/update
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Setup neovim lua configuration
 | 
					-- Setup neovim lua configuration
 | 
				
			||||||
require('neodev').setup()
 | 
					require('neodev').setup()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,18 +1,137 @@
 | 
				
			||||||
-- Unless you are still migrating, remove the deprecated commands from v1.x
 | 
					 | 
				
			||||||
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
return {
 | 
					return {
 | 
				
			||||||
  "nvim-neo-tree/neo-tree.nvim",
 | 
					  "nvim-neo-tree/neo-tree.nvim",
 | 
				
			||||||
  version = "*",
 | 
					  dependencies = { "MunifTanjim/nui.nvim" },
 | 
				
			||||||
  dependencies = {
 | 
					  cmd = "Neotree",
 | 
				
			||||||
    "nvim-lua/plenary.nvim",
 | 
					  init = function() vim.g.neo_tree_remove_legacy_commands = true end,
 | 
				
			||||||
    "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
 | 
					  opts = function()
 | 
				
			||||||
    "MunifTanjim/nui.nvim",
 | 
					    return {
 | 
				
			||||||
 | 
					      auto_clean_after_session_restore = true,
 | 
				
			||||||
 | 
					      close_if_last_window = true,
 | 
				
			||||||
 | 
					      sources = { "filesystem", "buffers", "git_status" },
 | 
				
			||||||
 | 
					      source_selector = {
 | 
				
			||||||
 | 
					        sources = {
 | 
				
			||||||
 | 
					          { source = "filesystem", display_name = "  Files " },
 | 
				
			||||||
 | 
					          { source = "git_status", display_name = "  Git " },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
  config = function ()
 | 
					      },
 | 
				
			||||||
    require('neo-tree').setup {}
 | 
					      default_component_configs = {
 | 
				
			||||||
 | 
					        icon = {
 | 
				
			||||||
 | 
					          folder_empty = "!",
 | 
				
			||||||
 | 
					          folder_empty_open = "!O",
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        git_status = {
 | 
				
			||||||
 | 
					          symbols = {
 | 
				
			||||||
 | 
					            renamed  = "",
 | 
				
			||||||
 | 
					            unstaged = "💣",
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      document_symbols = {
 | 
				
			||||||
 | 
					        kinds = {
 | 
				
			||||||
 | 
					          File = { icon = "", hl = "Tag" },
 | 
				
			||||||
 | 
					          Namespace = { icon = "", hl = "Include" },
 | 
				
			||||||
 | 
					          Package = { icon = "", hl = "Label" },
 | 
				
			||||||
 | 
					          Class = { icon = "", hl = "Include" },
 | 
				
			||||||
 | 
					          Property = { icon = "", hl = "@property" },
 | 
				
			||||||
 | 
					          Enum = { icon = "", hl = "@number" },
 | 
				
			||||||
 | 
					          Function = { icon = "", hl = "Function" },
 | 
				
			||||||
 | 
					          String = { icon = "", hl = "String" },
 | 
				
			||||||
 | 
					          Number = { icon = "", hl = "Number" },
 | 
				
			||||||
 | 
					          Array = { icon = "", hl = "Type" },
 | 
				
			||||||
 | 
					          Object = { icon = "", hl = "Type" },
 | 
				
			||||||
 | 
					          Key = { icon = "", hl = "" },
 | 
				
			||||||
 | 
					          Struct = { icon = "", hl = "Type" },
 | 
				
			||||||
 | 
					          Operator = { icon = "", hl = "Operator" },
 | 
				
			||||||
 | 
					          TypeParameter = { icon = "", hl = "Type" },
 | 
				
			||||||
 | 
					          StaticMethod = { icon = ' ', hl = 'Function' },
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      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,
 | 
					        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 results = {
 | 
				
			||||||
 | 
					            e = { val = modify(filename, ":e"), msg = "Extension only" },
 | 
				
			||||||
 | 
					            f = { val = filename, msg = "Filename" },
 | 
				
			||||||
 | 
					            F = { val = modify(filename, ":r"), msg = "Filename w/o extension" },
 | 
				
			||||||
 | 
					            h = { val = modify(filepath, ":~"), msg = "Path relative to Home" },
 | 
				
			||||||
 | 
					            p = { val = modify(filepath, ":."), msg = "Path relative to CWD" },
 | 
				
			||||||
 | 
					            P = { val = filepath, msg = "Absolute path" },
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- The line beneath this is called `modeline`. See `:help modeline`
 | 
					          local messages = {
 | 
				
			||||||
-- vim: ts=2 sts=2 sw=2 et
 | 
					            { "\nChoose to copy to clipboard:\n", "Normal" },
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          for i, result in pairs(results) do
 | 
				
			||||||
 | 
					            if result.val and result.val ~= "" then
 | 
				
			||||||
 | 
					              vim.list_extend(messages, {
 | 
				
			||||||
 | 
					                { ("%s."):format(i),           "Identifier" },
 | 
				
			||||||
 | 
					                { (" %s: "):format(result.msg) },
 | 
				
			||||||
 | 
					                { result.val,                  "String" },
 | 
				
			||||||
 | 
					                { "\n" },
 | 
				
			||||||
 | 
					              })
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          vim.api.nvim_echo(messages, false, {})
 | 
				
			||||||
 | 
					          local result = results[vim.fn.getcharstr()]
 | 
				
			||||||
 | 
					          if result and result.val and result.val ~= "" then
 | 
				
			||||||
 | 
					            vim.fn.setreg("+", result.val)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end,
 | 
				
			||||||
 | 
					        find_in_dir = function(state)
 | 
				
			||||||
 | 
					          local node = state.tree:get_node()
 | 
				
			||||||
 | 
					          local path = node:get_id()
 | 
				
			||||||
 | 
					          require("telescope.builtin").find_files {
 | 
				
			||||||
 | 
					            cwd = node.type == "directory" and path or vim.fn.fnamemodify(path, ":h"),
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        end,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      window = {
 | 
				
			||||||
 | 
					        width = 30,
 | 
				
			||||||
 | 
					        mappings = {
 | 
				
			||||||
 | 
					          ["<space>"] = false, -- disable space until we figure out which-key disabling
 | 
				
			||||||
 | 
					          ["[b"] = "prev_source",
 | 
				
			||||||
 | 
					          ["]b"] = "next_source",
 | 
				
			||||||
 | 
					          Y = "copy_selector",
 | 
				
			||||||
 | 
					          h = "parent_or_close",
 | 
				
			||||||
 | 
					          l = "child_or_open",
 | 
				
			||||||
 | 
					          o = "open",
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      filesystem = {
 | 
				
			||||||
 | 
					        follow_current_file = true,
 | 
				
			||||||
 | 
					        hijack_netrw_behavior = "open_current",
 | 
				
			||||||
 | 
					        use_libuv_file_watcher = true,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      event_handlers = {
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          event = "neo_tree_buffer_enter",
 | 
				
			||||||
 | 
					          handler = function(_) vim.opt_local.signcolumn = "auto" end,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  end,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,3 +72,5 @@ return {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  end,
 | 
					  end,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					-- The line beneath this is called `modeline`. See `:help modeline`
 | 
				
			||||||
 | 
					-- vim: ts=2 sts=2 sw=2 et
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue