Compare commits

...

6 commits

Author SHA1 Message Date
DamitusThyYeetus123
889f688f70
Merge 6d07646fae into 18bf52e540 2024-12-04 07:37:02 +01:00
Soliprem
18bf52e540
languages/gleam: init (#482)
Some checks are pending
Check for typos in the source tree / check-typos (push) Waiting to run
* modules/gleam: init

* gleam: not using formatter

* configuration: gleam set to false

* docs: added changelog entry for gleam

* gleam: fixed lsp and treesitter

* gleam: capitalisation
2024-12-04 02:43:16 +03:00
damii
6d07646fae Fix formatting 2024-12-04 09:35:25 +11:00
Ching Pei Yang
14de965ce9
formatting 2024-12-03 01:31:48 +01:00
DamitusThyYeetus123
234ad31909
Merge branch 'NotAShelf:v0.7' into v0.7 2024-12-03 09:13:34 +11:00
DamitusThyYeetus123
73cc5edd31 nvim-tree: Add directory opening 2024-11-12 13:25:08 +11:00
5 changed files with 82 additions and 1 deletions

View file

@ -65,6 +65,7 @@ isMaximal: {
python.enable = isMaximal;
dart.enable = isMaximal;
bash.enable = isMaximal;
gleam.enable = false;
r.enable = isMaximal;
tailwind.enable = isMaximal;
typst.enable = isMaximal;

View file

@ -359,6 +359,7 @@ The changes are, in no particular order:
- Add LSP and Treesitter support for Assembly under `vim.languages.assembly`
- Move [which-key](https://github.com/folke/which-key.nvim) to the new spec
- Add LSP and Treesitter support for Nushell under `vim.languages.nu`
- Add LSP and Treesitter support for Gleam under `vim.languages.gleam`
[Bloxx12](https://github.com/Bloxx12)

View file

@ -77,6 +77,9 @@ in {
-- buffer is a real file on the disk
local real_file = vim.fn.filereadable(data.file) == 1
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
-- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
@ -84,7 +87,7 @@ in {
local filetype = vim.bo[data.buf].ft
-- only files please
if not real_file and not no_name then
if not real_file and not directory and not no_name then
return
end
@ -93,6 +96,10 @@ in {
return
end
-- cd if buffer is a directory
if directory then
vim.cmd.cd(data.file)
end
-- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false })
end

View file

@ -9,6 +9,7 @@ in {
./clang.nix
./css.nix
./elixir.nix
./gleam.nix
./go.nix
./hcl.nix
./kotlin.nix

View file

@ -0,0 +1,71 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.gleam;
defaultServer = "gleam";
servers = {
gleam = {
package = pkgs.gleam;
lspConfig = ''
lspconfig.gleam.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/gleam", "lsp"}''
}
}
'';
};
};
in {
options.vim.languages.gleam = {
enable = mkEnableOption "Gleam language support";
treesitter = {
enable = mkEnableOption "Gleam treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "gleam";
};
lsp = {
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "Gleam LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "Gleam LSP server package, or the command to run as a list of strings";
};
};
};
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.gleam-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}