mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 02:52:37 +00:00 
			
		
		
		
	languages/go: add gofmt, golines and gofumpt formatter (#654)
	
		
			
	
		
	
	
		
	
		
			Some checks are pending
		
		
	
	
		
			
				
	
				Set up binary cache / cachix (default) (push) Waiting to run
				
			
		
			
				
	
				Set up binary cache / cachix (maximal) (push) Waiting to run
				
			
		
			
				
	
				Set up binary cache / cachix (nix) (push) Waiting to run
				
			
		
			
				
	
				Validate flake & check documentation / Validate Flake Documentation (push) Waiting to run
				
			
		
			
				
	
				Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Waiting to run
				
			
		
			
				
	
				Validate flake & check formatting / Validate Flake (push) Waiting to run
				
			
		
			
				
	
				Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
				
			
		
			
				
	
				Build and deploy documentation / Check latest commit (push) Waiting to run
				
			
		
			
				
	
				Build and deploy documentation / publish (push) Blocked by required conditions
				
			
		
			
				
	
				Check for typos in the source tree / check-typos (push) Waiting to run
				
			
		
		
	
	
		
	
		
			Some checks are pending
		
		
	
	Set up binary cache / cachix (default) (push) Waiting to run
				
			Set up binary cache / cachix (maximal) (push) Waiting to run
				
			Set up binary cache / cachix (nix) (push) Waiting to run
				
			Validate flake & check documentation / Validate Flake Documentation (push) Waiting to run
				
			Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Waiting to run
				
			Validate flake & check formatting / Validate Flake (push) Waiting to run
				
			Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
				
			Build and deploy documentation / Check latest commit (push) Waiting to run
				
			Build and deploy documentation / publish (push) Blocked by required conditions
				
			Check for typos in the source tree / check-typos (push) Waiting to run
				
			This commit is contained in:
		
					parent
					
						
							
								e42bcbe1ec
							
						
					
				
			
			
				commit
				
					
						54476b5a8b
					
				
			
		
					 2 changed files with 59 additions and 0 deletions
				
			
		|  | @ -170,3 +170,4 @@ | |||
| [Libadoxon](https://github.com/Libadoxon) | ||||
| 
 | ||||
| - Add [git-conflict](https://github.com/akinsho/git-conflict.nvim) plugin for resolving git conflicts | ||||
| - Add formatters for go: [gofmt](https://go.dev/blog/gofmt), [golines](https://github.com/segmentio/golines) and [gofumpt](https://github.com/mvdan/gofumpt) | ||||
|  |  | |||
|  | @ -34,6 +34,43 @@ | |||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   defaultFormat = "gofmt"; | ||||
|   formats = { | ||||
|     gofmt = { | ||||
|       package = pkgs.go; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.gofmt.with({ | ||||
|             command = "${cfg.format.package}/bin/gofmt", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
|     gofumpt = { | ||||
|       package = pkgs.gofumpt; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.gofumpt.with({ | ||||
|             command = "${cfg.format.package}/bin/gofumpt", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
|     golines = { | ||||
|       package = pkgs.golines; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.golines.with({ | ||||
|             command = "${cfg.format.package}/bin/golines", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   defaultDebugger = "delve"; | ||||
|   debuggers = { | ||||
|     delve = { | ||||
|  | @ -67,6 +104,22 @@ in { | |||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     format = { | ||||
|       enable = mkEnableOption "Go formatting" // {default = config.vim.languages.enableFormat;}; | ||||
| 
 | ||||
|       type = mkOption { | ||||
|         description = "Go formatter to use"; | ||||
|         type = enum (attrNames formats); | ||||
|         default = defaultFormat; | ||||
|       }; | ||||
| 
 | ||||
|       package = mkOption { | ||||
|         description = "Go formatter package"; | ||||
|         type = package; | ||||
|         default = formats.${cfg.format.type}.package; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     dap = { | ||||
|       enable = mkOption { | ||||
|         description = "Enable Go Debug Adapter via nvim-dap-go plugin"; | ||||
|  | @ -99,6 +152,11 @@ in { | |||
|       vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.format.enable { | ||||
|       vim.lsp.null-ls.enable = true; | ||||
|       vim.lsp.null-ls.sources.go-format = formats.${cfg.format.type}.nullConfig; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.dap.enable { | ||||
|       vim = { | ||||
|         startPlugins = ["nvim-dap-go"]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue