Skip to content

Commit

Permalink
usr: cli: vim: group metals settings
Browse files Browse the repository at this point in the history
  • Loading branch information
xieby1 committed Nov 20, 2023
1 parent 880f23d commit 7947569
Showing 1 changed file with 61 additions and 52 deletions.
113 changes: 61 additions & 52 deletions usr/cli/vim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -463,44 +463,69 @@ let
})
'';
};
jre_with_proxy = pkgs.callPackage ./jre_with_proxy.nix {
jre = pkgs.openjdk8_headless;
proxyHost = "127.0.0.1";
proxyPort = "${toString config.proxyPort}";
};
my-nvim-metals = {
plugin = pkgs.vimPlugins.nvim-metals;
type = "lua";
config = ''
-- lspconfig.metals.setup{}
local metals_config = require("metals").bare_config()
metals_config.settings = {
showImplicitArguments = true,
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
serverProperties = {
"-Dhttps.proxyHost=127.0.0.1",
"-Dhttps.proxyPort=${toString config.proxyPort}",
"-Dhttp.proxyHost=127.0.0.1",
"-Dhttp.proxyPort=${toString config.proxyPort}",
},
-- see `:h metalsBinaryPath`, "Another setting for you crazy Nix kids." Hahaha!
metalsBinaryPath = "${pkgs.metals.override {jre = jre_with_proxy;}}/bin/metals",
javaHome = "${jre_with_proxy}",
}
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Autocmd that will actually be in charging of starting the whole thing
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = nvim_metals_group,
pattern = { "scala", "sbt" },
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
})
'';
};
in
{
imports = [(let
jre_with_proxy = pkgs.callPackage ./jre_with_proxy.nix {
jre = pkgs.openjdk8_headless;
proxyHost = "127.0.0.1";
proxyPort = "${toString config.proxyPort}";
};
my-nvim-metals = {
plugin = pkgs.vimPlugins.nvim-metals;
type = "lua";
config = ''
-- lspconfig.metals.setup{}
local metals_config = require("metals").bare_config()
metals_config.settings = {
showImplicitArguments = true,
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
serverProperties = {
"-Dhttps.proxyHost=127.0.0.1",
"-Dhttps.proxyPort=${toString config.proxyPort}",
"-Dhttp.proxyHost=127.0.0.1",
"-Dhttp.proxyPort=${toString config.proxyPort}",
},
-- see `:h metalsBinaryPath`, "Another setting for you crazy Nix kids." Hahaha!
metalsBinaryPath = "${pkgs.metals.override {jre = jre_with_proxy;}}/bin/metals",
javaHome = "${jre_with_proxy}",
}
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Autocmd that will actually be in charging of starting the whole thing
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = nvim_metals_group,
pattern = { "scala", "sbt" },
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
})
'';
};
in {
programs.neovim = {
plugins = with pkgs.vimPlugins; [
my-nvim-metals
];
extraPackages = with pkgs; [
(coursier.override {
jre = jre_with_proxy;
})
];

};
# nvim-metals proxy for bloop
home.file.jvmopts = {
text = ''
-Dhttps.proxyHost=127.0.0.1
-Dhttps.proxyPort=${toString config.proxyPort}
-Dhttp.proxyHost=127.0.0.1
-Dhttp.proxyPort=${toString config.proxyPort}
'';
target = ".bloop/.jvmopts";
};
})];

# neovim
programs.bash.shellAliases.view = "nvim -R";
# nvim as manpager
Expand Down Expand Up @@ -746,18 +771,13 @@ in
my-cmp-tabnine

my-hbac
my-nvim-metals
] ++ (lib.optional config.isGui markdown-preview-nvim);
vimdiffAlias = true;
extraPackages = with pkgs; [
ccls
ltex-ls
ripgrep
pkgsu.nixd
# nvim-metals
(coursier.override {
jre = jre_with_proxy;
})
];

# coc
Expand Down Expand Up @@ -945,15 +965,4 @@ in
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
'';
};

# nvim-metals proxy for bloop
home.file.jvmopts = {
text = ''
-Dhttps.proxyHost=127.0.0.1
-Dhttps.proxyPort=${toString config.proxyPort}
-Dhttp.proxyHost=127.0.0.1
-Dhttp.proxyPort=${toString config.proxyPort}
'';
target = ".bloop/.jvmopts";
};
}

0 comments on commit 7947569

Please sign in to comment.