mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	convert lua module
This commit is contained in:
		
					parent
					
						
							
								16c7c28ba1
							
						
					
				
			
			
				commit
				
					
						c743bca93f
					
				
			
		
					 1 changed files with 34 additions and 22 deletions
				
			
		|  | @ -8,13 +8,32 @@ | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   inherit (lib.options) mkEnableOption mkOption; | ||||||
|   inherit (lib.modules) mkIf mkMerge; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|   inherit (lib.meta) getExe; |   inherit (lib.meta) getExe; | ||||||
|   inherit (lib.lists) isList; |   inherit (lib.types) bool enum listOf package; | ||||||
|   inherit (lib.types) bool either enum listOf package str; |  | ||||||
|   inherit (lib.nvim.types) diagnostics mkGrammarOption; |   inherit (lib.nvim.types) diagnostics mkGrammarOption; | ||||||
|   inherit (lib.nvim.lua) expToLua; |  | ||||||
|   inherit (lib.nvim.dag) entryBefore; |   inherit (lib.nvim.dag) entryBefore; | ||||||
|  |   inherit (lib.nvim.attrsets) mapListToAttrs; | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.languages.lua; |   cfg = config.vim.languages.lua; | ||||||
|  | 
 | ||||||
|  |   defaultServers = ["lua-language-server"]; | ||||||
|  |   servers = { | ||||||
|  |     lua-language-server = { | ||||||
|  |       enable = true; | ||||||
|  |       cmd = [(getExe pkgs.lua-language-server)]; | ||||||
|  |       filetypes = ["lua"]; | ||||||
|  |       root_markers = [ | ||||||
|  |         ".luarc.json" | ||||||
|  |         ".luarc.jsonc" | ||||||
|  |         ".luacheckrc" | ||||||
|  |         ".stylua.toml" | ||||||
|  |         "stylua.toml" | ||||||
|  |         "selene.toml" | ||||||
|  |         "selene.yml" | ||||||
|  |         ".git" | ||||||
|  |       ]; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|   defaultFormat = "stylua"; |   defaultFormat = "stylua"; | ||||||
|   formats = { |   formats = { | ||||||
|     stylua = { |     stylua = { | ||||||
|  | @ -43,12 +62,11 @@ in { | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     lsp = { |     lsp = { | ||||||
|       enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.lsp.enable;}; |       enable = mkEnableOption "Lua LSP support" // {default = config.vim.lsp.enable;}; | ||||||
| 
 |       servers = mkOption { | ||||||
|       package = mkOption { |         description = "Lua LSP server to use"; | ||||||
|         description = "LuaLS package, or the command to run as a list of strings"; |         type = listOf (enum (attrNames servers)); | ||||||
|         type = either package (listOf str); |         default = defaultServers; | ||||||
|         default = pkgs.lua-language-server; |  | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers"; |       lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers"; | ||||||
|  | @ -91,23 +109,17 @@ in { | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.enable (mkMerge [ |     (mkIf cfg.enable (mkMerge [ | ||||||
|       (mkIf cfg.lsp.enable { |       (mkIf cfg.lsp.enable { | ||||||
|         vim.lsp.lspconfig.enable = true; |         vim.lsp.servers = | ||||||
|         vim.lsp.lspconfig.sources.lua-lsp = '' |           mapListToAttrs (n: { | ||||||
|           lspconfig.lua_ls.setup { |             name = n; | ||||||
|             capabilities = capabilities; |             value = servers.${n}; | ||||||
|             on_attach = default_on_attach; |           }) | ||||||
|             cmd = ${ |           cfg.lsp.servers; | ||||||
|             if isList cfg.lsp.package |  | ||||||
|             then expToLua cfg.lsp.package |  | ||||||
|             else ''{"${getExe cfg.lsp.package}"}'' |  | ||||||
|           }; |  | ||||||
|           } |  | ||||||
|         ''; |  | ||||||
|       }) |       }) | ||||||
| 
 | 
 | ||||||
|       (mkIf cfg.lsp.lazydev.enable { |       (mkIf cfg.lsp.lazydev.enable { | ||||||
|         vim.startPlugins = ["lazydev-nvim"]; |         vim.startPlugins = ["lazydev-nvim"]; | ||||||
|         vim.pluginRC.lazydev = entryBefore ["lua-lsp"] '' |         vim.pluginRC.lazydev = entryBefore ["lsp-servers"] '' | ||||||
|           require("lazydev").setup({ |           require("lazydev").setup({ | ||||||
|             enabled = function(root_dir) |             enabled = function(root_dir) | ||||||
|               return not vim.uv.fs_stat(root_dir .. "/.luarc.json") |               return not vim.uv.fs_stat(root_dir .. "/.luarc.json") | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sjcobb
				sjcobb