mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 02:52:37 +00:00 
			
		
		
		
	languages/fsharp: convert module
This commit is contained in:
		
					parent
					
						
							
								25f4d62f6a
							
						
					
				
			
			
				commit
				
					
						43bbd6c721
					
				
			
		
					 1 changed files with 27 additions and 32 deletions
				
			
		|  | @ -5,30 +5,31 @@ | |||
|   ... | ||||
| }: let | ||||
|   inherit (builtins) attrNames; | ||||
|   inherit (lib.generators) mkLuaInline; | ||||
|   inherit (lib.options) mkEnableOption mkOption; | ||||
|   inherit (lib.types) either listOf package str enum; | ||||
|   inherit (lib.types) package enum; | ||||
|   inherit (lib.meta) getExe; | ||||
|   inherit (lib.modules) mkIf mkMerge; | ||||
|   inherit (lib.lists) isList; | ||||
|   inherit (lib.nvim.types) mkGrammarOption; | ||||
|   inherit (lib.nvim.lua) expToLua; | ||||
|   inherit (lib.nvim.attrsets) mapListToAttrs; | ||||
|   inherit (lib.nvim.types) mkGrammarOption mkServersOption; | ||||
| 
 | ||||
|   defaultServer = "fsautocomplete"; | ||||
|   defaultServers = ["fsautocomplete"]; | ||||
|   servers = { | ||||
|     fsautocomplete = { | ||||
|       package = pkgs.fsautocomplete; | ||||
|       internalFormatter = false; | ||||
|       lspConfig = '' | ||||
|         lspconfig.fsautocomplete.setup { | ||||
|           capabilities = capabilities; | ||||
|           on_attach = default_on_attach; | ||||
|           cmd = ${ | ||||
|           if isList cfg.lsp.package | ||||
|           then expToLua cfg.lsp.package | ||||
|           else "{'${cfg.lsp.package}/bin/fsautocomplete'}" | ||||
|         }, | ||||
|         } | ||||
|       ''; | ||||
|       enable = true; | ||||
|       cmd = [(getExe pkgs.fsautocomplete)]; | ||||
|       filetypes = ["fsharp"]; | ||||
|       root_dir = | ||||
|         mkLuaInline | ||||
|         /* | ||||
|         lua | ||||
|         */ | ||||
|         '' | ||||
|           function(bufnr, on_dir) | ||||
|             local fname = vim.api.nvim_buf_get_name(bufnr) | ||||
|             on_dir(util.root_pattern('*.sln', '*.fsproj', '.git')(fname)) | ||||
|           end, | ||||
|         ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|  | @ -52,19 +53,9 @@ in { | |||
| 
 | ||||
|       lsp = { | ||||
|         enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;}; | ||||
|         server = mkOption { | ||||
|           type = enum (attrNames servers); | ||||
|           default = defaultServer; | ||||
|           description = "F# LSP server to use"; | ||||
|         }; | ||||
| 
 | ||||
|         package = mkOption { | ||||
|           type = either package (listOf str); | ||||
|           default = servers.${cfg.lsp.server}.package; | ||||
|           example = ''[lib.getExe pkgs.fsautocomplete "--state-directory" "~/.cache/fsautocomplete"]''; | ||||
|           description = "F# LSP server package, or the command to run as a list of strings"; | ||||
|         }; | ||||
|         servers = mkServersOption "F#" servers defaultServers; | ||||
|       }; | ||||
| 
 | ||||
|       format = { | ||||
|         enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;}; | ||||
| 
 | ||||
|  | @ -90,8 +81,12 @@ in { | |||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.lsp.enable { | ||||
|       vim.lsp.lspconfig.enable = true; | ||||
|       vim.lsp.lspconfig.sources.fsharp-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|       vim.lsp.servers = | ||||
|         mapListToAttrs (n: { | ||||
|           name = n; | ||||
|           value = servers.${n}; | ||||
|         }) | ||||
|         cfg.lsp.servers; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.format.enable { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 poz
				poz