mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	language/fsharp: migrate to vim.lsp.servers
This commit is contained in:
		
					parent
					
						
							
								4c83dd5895
							
						
					
				
			
			
				commit
				
					
						b4f34299ce
					
				
			
		
					 1 changed files with 43 additions and 27 deletions
				
			
		|  | @ -6,29 +6,48 @@ | ||||||
| }: let | }: let | ||||||
|   inherit (builtins) attrNames; |   inherit (builtins) attrNames; | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   inherit (lib.options) mkEnableOption mkOption; | ||||||
|   inherit (lib.types) either listOf package str enum; |   inherit (lib.types) listOf package enum; | ||||||
|   inherit (lib.meta) getExe; |   inherit (lib.meta) getExe; | ||||||
|   inherit (lib.modules) mkIf mkMerge; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|   inherit (lib.lists) isList; |   inherit (lib.generators) mkLuaInline; | ||||||
|   inherit (lib.nvim.types) mkGrammarOption; |   inherit (lib.nvim.types) mkGrammarOption; | ||||||
|   inherit (lib.nvim.lua) expToLua; |   inherit (lib.nvim.attrsets) mapListToAttrs; | ||||||
| 
 | 
 | ||||||
|   defaultServer = "fsautocomplete"; |   defaultServer = ["fsautocomplete"]; | ||||||
|   servers = { |   servers = { | ||||||
|     fsautocomplete = { |     fsautocomplete = { | ||||||
|       package = pkgs.fsautocomplete; |       cmd = [(getExe pkgs.fsautocomplete) "--adaptive-lsp-server-enabled"]; | ||||||
|       internalFormatter = false; |       filetypes = ["fsharp"]; | ||||||
|       lspConfig = '' |       root_dir = mkLuaInline '' | ||||||
|         lspconfig.fsautocomplete.setup { |         function(bufnr, on_dir) | ||||||
|           capabilities = capabilities; |           on_dir(vim.fs.root(bufnr, function(name, path) | ||||||
|           on_attach = default_on_attach; |             return name == ".git" or name:match("%.sln$") or name:match("%.fsproj$") | ||||||
|           cmd = ${ |           end)) | ||||||
|           if isList cfg.lsp.package |         end | ||||||
|           then expToLua cfg.lsp.package |  | ||||||
|           else "{'${cfg.lsp.package}/bin/fsautocomplete'}" |  | ||||||
|         }, |  | ||||||
|         } |  | ||||||
|       ''; |       ''; | ||||||
|  |       init_options = { | ||||||
|  |         AutomaticWorkspaceInit = true; | ||||||
|  |       }; | ||||||
|  |       settings = { | ||||||
|  |         FSharp = { | ||||||
|  |           keywordsAutocomplete = true; | ||||||
|  |           ExternalAutocomplete = false; | ||||||
|  |           Linter = true; | ||||||
|  |           UnionCaseStubGeneration = true; | ||||||
|  |           UnionCaseStubGenerationBody = ''failwith "Not Implemented"''; | ||||||
|  |           RecordStubGeneration = true; | ||||||
|  |           RecordStubGenerationBody = ''failwith "Not Implemented"''; | ||||||
|  |           InterfaceStubGeneration = true; | ||||||
|  |           InterfaceStubGenerationObjectIdentifier = "this"; | ||||||
|  |           InterfaceStubGenerationMethodBody = ''failwith "Not Implemented"''; | ||||||
|  |           UnusedOpensAnalyzer = true; | ||||||
|  |           UnusedDeclarationsAnalyzer = true; | ||||||
|  |           UseSdkScripts = true; | ||||||
|  |           SimplifyNameAnalyzer = true; | ||||||
|  |           ResolveNamespaces = true; | ||||||
|  |           EnableReferenceCodeLens = true; | ||||||
|  |         }; | ||||||
|  |       }; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  | @ -52,18 +71,11 @@ in { | ||||||
| 
 | 
 | ||||||
|       lsp = { |       lsp = { | ||||||
|         enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;}; |         enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;}; | ||||||
|         server = mkOption { |         servers = mkOption { | ||||||
|           type = enum (attrNames servers); |           type = listOf (enum (attrNames servers)); | ||||||
|           default = defaultServer; |           default = defaultServer; | ||||||
|           description = "F# LSP server to use"; |           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"; |  | ||||||
|         }; |  | ||||||
|       }; |       }; | ||||||
|       format = { |       format = { | ||||||
|         enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;}; |         enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;}; | ||||||
|  | @ -90,8 +102,12 @@ in { | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.lsp.enable { |     (mkIf cfg.lsp.enable { | ||||||
|       vim.lsp.lspconfig.enable = true; |       vim.lsp.servers = | ||||||
|       vim.lsp.lspconfig.sources.fsharp-lsp = servers.${cfg.lsp.server}.lspConfig; |         mapListToAttrs (name: { | ||||||
|  |           inherit name; | ||||||
|  |           value = servers.${name}; | ||||||
|  |         }) | ||||||
|  |         cfg.lsp.servers; | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.format.enable { |     (mkIf cfg.format.enable { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ching Pei Yang
				Ching Pei Yang