mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	convert elixir module
This commit is contained in:
		
					parent
					
						
							
								e970eac1af
							
						
					
				
			
			
				commit
				
					
						161235da30
					
				
			
		
					 1 changed files with 31 additions and 27 deletions
				
			
		|  | @ -8,28 +8,36 @@ | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   inherit (lib.options) mkEnableOption mkOption; | ||||||
|   inherit (lib.modules) mkIf mkMerge; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|   inherit (lib.lists) isList; |   inherit (lib.lists) isList; | ||||||
|  |   inherit (lib.meta) getExe; | ||||||
|   inherit (lib.types) enum either listOf package str; |   inherit (lib.types) enum either listOf package str; | ||||||
|  |   inherit (lib.generators) mkLuaInline; | ||||||
|   inherit (lib.nvim.types) mkGrammarOption; |   inherit (lib.nvim.types) mkGrammarOption; | ||||||
|   inherit (lib.nvim.lua) expToLua; |   inherit (lib.nvim.lua) expToLua; | ||||||
|   inherit (lib.nvim.dag) entryAnywhere; |   inherit (lib.nvim.dag) entryAnywhere; | ||||||
|  |   inherit (lib.nvim.attrsets) mapListToAttrs; | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.languages.elixir; |   cfg = config.vim.languages.elixir; | ||||||
| 
 | 
 | ||||||
|   defaultServer = "elixirls"; |   defaultServers = ["elixirls"]; | ||||||
|   servers = { |   servers = { | ||||||
|     elixirls = { |     elixirls = { | ||||||
|       package = pkgs.elixir-ls; |       enable = true; | ||||||
|       lspConfig = '' |       cmd = [(getExe pkgs.elixir-ls)]; | ||||||
|         -- elixirls setup |       filetypes = ["elixir" "eelixir" "heex" "surface"]; | ||||||
|         lspconfig.elixirls.setup { |       root_dir = | ||||||
|           capabilities = capabilities, |         mkLuaInline | ||||||
|           on_attach = default_on_attach, |         /* | ||||||
|           cmd = ${ |         lua | ||||||
|           if isList cfg.lsp.package |         */ | ||||||
|           then expToLua cfg.lsp.package |         '' | ||||||
|           else ''{"${cfg.lsp.package}/bin/elixir-ls"}'' |           function(bufnr, on_dir) | ||||||
|         } |             local fname = vim.api.nvim_buf_get_name(bufnr) | ||||||
|         } |             local matches = vim.fs.find({ 'mix.exs' }, { upward = true, limit = 2, path = fname }) | ||||||
|  |             local child_or_root_path, maybe_umbrella_path = unpack(matches) | ||||||
|  |             local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path) | ||||||
|  | 
 | ||||||
|  |             on_dir(root_dir) | ||||||
|  |           end | ||||||
|         ''; |         ''; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|  | @ -54,18 +62,10 @@ in { | ||||||
| 
 | 
 | ||||||
|     lsp = { |     lsp = { | ||||||
|       enable = mkEnableOption "Elixir LSP support" // {default = config.vim.lsp.enable;}; |       enable = mkEnableOption "Elixir LSP support" // {default = config.vim.lsp.enable;}; | ||||||
| 
 |       servers = mkOption { | ||||||
|       server = mkOption { |  | ||||||
|         description = "Elixir LSP server to use"; |         description = "Elixir LSP server to use"; | ||||||
|         type = enum (attrNames servers); |         type = listOf (enum (attrNames servers)); | ||||||
|         default = defaultServer; |         default = defaultServers; | ||||||
|       }; |  | ||||||
| 
 |  | ||||||
|       package = mkOption { |  | ||||||
|         description = "Elixir LSP server package, or the command to run as a list of strings"; |  | ||||||
|         example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; |  | ||||||
|         type = either package (listOf str); |  | ||||||
|         default = servers.${cfg.lsp.server}.package; |  | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -97,8 +97,12 @@ in { | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.lsp.enable { |     (mkIf cfg.lsp.enable { | ||||||
|       vim.lsp.lspconfig.enable = true; |       vim.lsp.servers = | ||||||
|       vim.lsp.lspconfig.sources.elixir-lsp = servers.${cfg.lsp.server}.lspConfig; |         mapListToAttrs (n: { | ||||||
|  |           name = n; | ||||||
|  |           value = servers.${n}; | ||||||
|  |         }) | ||||||
|  |         cfg.lsp.servers; | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.format.enable { |     (mkIf cfg.format.enable { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sjcobb
				sjcobb