mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	treewide: begin restructuring the module tree
This commit is contained in:
		
					parent
					
						
							
								e1835f6c46
							
						
					
				
			
			
				commit
				
					
						7c730a78e5
					
				
			
		
					 254 changed files with 749 additions and 664 deletions
				
			
		
							
								
								
									
										76
									
								
								modules/plugins/languages/dart/config.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								modules/plugins/languages/dart/config.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,76 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   pkgs, | ||||
|   ... | ||||
| }: let | ||||
|   inherit (lib.lists) isList; | ||||
|   inherit (lib.modules) mkIf mkMerge; | ||||
|   inherit (lib.strings) optionalString; | ||||
|   inherit (lib.trivial) boolToString; | ||||
|   inherit (lib.nvim.lua) expToLua; | ||||
|   inherit (lib.nvim.dag) entryAnywhere; | ||||
| 
 | ||||
|   cfg = config.vim.languages.dart; | ||||
|   ftcfg = cfg.flutter-tools; | ||||
|   servers = { | ||||
|     dart = { | ||||
|       package = pkgs.dart; | ||||
|       lspConfig = '' | ||||
|         lspconfig.dartls.setup{ | ||||
|           capabilities = capabilities; | ||||
|           on_attach=default_on_attach; | ||||
|           cmd = ${ | ||||
|           if isList cfg.lsp.package | ||||
|           then expToLua cfg.lsp.package | ||||
|           else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' | ||||
|         }; | ||||
|           ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} | ||||
|         } | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| in { | ||||
|   config = mkIf cfg.enable (mkMerge [ | ||||
|     (mkIf cfg.treesitter.enable { | ||||
|       vim.treesitter.enable = true; | ||||
|       vim.treesitter.grammars = [cfg.treesitter.package]; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.lsp.enable { | ||||
|       vim.lsp.lspconfig.enable = true; | ||||
| 
 | ||||
|       vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf ftcfg.enable { | ||||
|       vim.startPlugins = | ||||
|         if ftcfg.enableNoResolvePatch | ||||
|         then ["flutter-tools-patched"] | ||||
|         else ["flutter-tools"]; | ||||
| 
 | ||||
|       vim.luaConfigRC.flutter-tools = entryAnywhere '' | ||||
|         require('flutter-tools').setup { | ||||
|           lsp = { | ||||
|             color = { -- show the derived colours for dart variables | ||||
|               enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 | ||||
|               background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background | ||||
|               foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground | ||||
|               virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text | ||||
|               virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight | ||||
|             }, | ||||
| 
 | ||||
|             capabilities = capabilities, | ||||
|             on_attach = default_on_attach; | ||||
|             flags = lsp_flags, | ||||
|           }, | ||||
|           ${optionalString cfg.dap.enable '' | ||||
|           debugger = { | ||||
|             enabled = true, | ||||
|           }, | ||||
|         ''} | ||||
|         } | ||||
|       ''; | ||||
|     }) | ||||
|   ]); | ||||
| } | ||||
							
								
								
									
										115
									
								
								modules/plugins/languages/dart/dart.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								modules/plugins/languages/dart/dart.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,115 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   pkgs, | ||||
|   ... | ||||
| }: let | ||||
|   inherit (builtins) attrNames; | ||||
|   inherit (lib.lists) isList; | ||||
|   inherit (lib.options) mkEnableOption mkOption; | ||||
|   inherit (lib.types) enum either listOf package nullOr str bool; | ||||
|   inherit (lib.strings) optionalString; | ||||
|   inherit (lib.nvim.lua) expToLua; | ||||
|   inherit (lib.nvim.types) mkGrammarOption; | ||||
| 
 | ||||
|   cfg = config.vim.languages.dart; | ||||
|   defaultServer = "dart"; | ||||
|   servers = { | ||||
|     dart = { | ||||
|       package = pkgs.dart; | ||||
|       lspConfig = '' | ||||
|         lspconfig.dartls.setup{ | ||||
|           capabilities = capabilities; | ||||
|           on_attach=default_on_attach; | ||||
|           cmd = ${ | ||||
|           if isList cfg.lsp.package | ||||
|           then expToLua cfg.lsp.package | ||||
|           else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' | ||||
|         }; | ||||
|           ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} | ||||
|         } | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| in { | ||||
|   options.vim.languages.dart = { | ||||
|     enable = mkEnableOption "Dart language support"; | ||||
| 
 | ||||
|     treesitter = { | ||||
|       enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;}; | ||||
|       package = mkGrammarOption pkgs "dart"; | ||||
|     }; | ||||
| 
 | ||||
|     lsp = { | ||||
|       enable = mkEnableOption "Dart LSP support"; | ||||
|       server = mkOption { | ||||
|         description = "The Dart LSP server to use"; | ||||
|         type = enum (attrNames servers); | ||||
|         default = defaultServer; | ||||
|       }; | ||||
|       package = mkOption { | ||||
|         description = "Dart 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; | ||||
|       }; | ||||
|       opts = mkOption { | ||||
|         description = "Options to pass to Dart LSP server"; | ||||
|         type = nullOr str; | ||||
|         default = null; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     dap = { | ||||
|       enable = mkOption { | ||||
|         description = "Enable Dart DAP support via flutter-tools"; | ||||
|         type = bool; | ||||
|         default = config.vim.languages.enableDAP; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     flutter-tools = { | ||||
|       enable = mkOption { | ||||
|         description = "Enable flutter-tools for flutter support"; | ||||
|         type = bool; | ||||
|         default = config.vim.languages.enableLSP; | ||||
|       }; | ||||
| 
 | ||||
|       enableNoResolvePatch = mkOption { | ||||
|         description = '' | ||||
|           Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path. | ||||
|           This is required if you want to use a flutter package built with nix. | ||||
|           If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option. | ||||
|         ''; | ||||
|         type = bool; | ||||
|         default = true; | ||||
|       }; | ||||
| 
 | ||||
|       color = { | ||||
|         enable = mkEnableOption "Whether or mot to highlight color variables at all"; | ||||
| 
 | ||||
|         highlightBackground = mkOption { | ||||
|           type = bool; | ||||
|           default = false; | ||||
|           description = "Highlight the background"; | ||||
|         }; | ||||
| 
 | ||||
|         highlightForeground = mkOption { | ||||
|           type = bool; | ||||
|           default = false; | ||||
|           description = "Highlight the foreground"; | ||||
|         }; | ||||
| 
 | ||||
|         virtualText = { | ||||
|           enable = mkEnableOption "Show the highlight using virtual text"; | ||||
| 
 | ||||
|           character = mkOption { | ||||
|             type = str; | ||||
|             default = "■"; | ||||
|             description = "Virtual text character to highlight"; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										6
									
								
								modules/plugins/languages/dart/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								modules/plugins/languages/dart/default.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| { | ||||
|   imports = [ | ||||
|     ./dart.nix | ||||
|     ./config.nix | ||||
|   ]; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue