mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-23 20:08:30 +00:00
Compare commits
7 commits
4858a6998c
...
88034ac4c6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88034ac4c6 | ||
614ad33a60 | |||
fdd0642c7d | |||
379d2a9f16 | |||
![]() |
78a52d75ca | ||
![]() |
7c5122abb0 | ||
![]() |
aa236a7f7e |
7 changed files with 218 additions and 30 deletions
74
.github/pull_request_template.md
vendored
74
.github/pull_request_template.md
vendored
|
@ -1,39 +1,57 @@
|
|||
# Description
|
||||
<!--
|
||||
^ Please include a clear and concise description of the aim of your Pull Request above this line ^
|
||||
|
||||
A clear and concise description of the aim of your Pull Request.
|
||||
For plugin dependency/module additions, please make sure to link the source link of the added plugin
|
||||
or dependency in this section.
|
||||
|
||||
**If your pull request aims to fix an open issue or a present bug, please link the relevant issue below. If not, please remove this section**
|
||||
Fixes #(issue)
|
||||
If your pull request aims to fix an open issue or a please bug, please also link the relevant issue
|
||||
below this line. You may attach an issue to your pull request with `Fixes #<issue number>` outside
|
||||
this comment.
|
||||
-->
|
||||
|
||||
## Type of change
|
||||
## Sanity Checking
|
||||
|
||||
Please delete any options that are not relevant.
|
||||
<!--
|
||||
Please check all that apply. As before, this section is not a hard requirement but checklists with more checked
|
||||
items are likely to be merged faster. You may save some time in maintainer review by performing self-reviews here
|
||||
before submitting your pull request.
|
||||
|
||||
- Bug fix (non-breaking change which fixes an issue)
|
||||
- New feature (non-breaking change which adds functionality)
|
||||
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- Translation/Language update
|
||||
- Docs
|
||||
- Other
|
||||
If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include
|
||||
it above in your description.
|
||||
-->
|
||||
|
||||
## Checklist
|
||||
[editorconfig]: https://editorconfig.org
|
||||
[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes
|
||||
|
||||
Please try to check at least a majority of the checklist before opening your pull request. Exceptions to this will be reviewed on a case by case basis.
|
||||
- [ ] I have updated the [changelog] as per my changes.
|
||||
- [ ] I have tested, and self-reviewed my code.
|
||||
- Style and consistency
|
||||
- [ ] I ran **Alejandra** to format my code (`nix fmt`).
|
||||
- [ ] My code conforms to the [editorconfig] configuration of the project.
|
||||
- [ ] My changes are consistent with the rest of the codebase.
|
||||
- If new changes are particularly complex:
|
||||
- [ ] My code includes comments in particularly complex areas
|
||||
- [ ] I have added a section in the manual.
|
||||
- [ ] _(For breaking changes)_ I have included a migration guide.
|
||||
- Package(s) built:
|
||||
- [ ] `.#nix` (default package)
|
||||
- [ ] `.#maximal`
|
||||
- [ ] `.#docs-html`
|
||||
- Tested on platform(s)
|
||||
- [ ] `x86_64-linux`
|
||||
- [ ] `aarch64-linux`
|
||||
- [ ] `x86_64-darwin`
|
||||
- [ ] `aarch64-darwin`
|
||||
|
||||
- [ ] My code follows the style and contributing guidelines of this project.
|
||||
- [ ] I ran Alejandra to format my code (`nix fmt`).
|
||||
- [ ] I have performed a self-review of my own code and tested it.
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas.
|
||||
- [ ] My changes generate no new warnings.
|
||||
- [ ] This change requires a documentation update.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
<!--
|
||||
If your changes touch upon a portion of the codebase that you do not understand well, please make sure to consult
|
||||
the maintainers on your changes. In most cases, making an issue before creating your PR will help you avoid duplicate
|
||||
efforts in the long run.
|
||||
-->
|
||||
|
||||
## Screenshots & Logs
|
||||
---
|
||||
|
||||
You are kindly requested to attach screenshots of your changes in actions and preferably your build/run logs for all available packages. If you are not sure how to do this, you can refer to the [documentation](https://notashelf.github.io/neovim-flake/).
|
||||
Add a :+1: [reaction] to [pull requests you find important].
|
||||
|
||||
**Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.**
|
||||
|
||||
```console
|
||||
# Paste your logs here
|
||||
```
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
|
|
@ -68,6 +68,7 @@ isMaximal: {
|
|||
lsp.server = "clangd";
|
||||
};
|
||||
|
||||
scala.enable = isMaximal;
|
||||
rust = {
|
||||
enable = isMaximal;
|
||||
crates.enable = isMaximal;
|
||||
|
|
|
@ -89,7 +89,8 @@ everyone.
|
|||
- Add [new-file-template.nvim] to automatically fill new file contents using
|
||||
templates
|
||||
|
||||
- Make [neo-tree.nvim] display file icons properly by enabling `visuals.nvimWebDevicons`
|
||||
- Make [neo-tree.nvim] display file icons properly by enabling
|
||||
`visuals.nvimWebDevicons`
|
||||
|
||||
[diniamo](https://github.com/diniamo):
|
||||
|
||||
|
@ -206,8 +207,12 @@ everyone.
|
|||
- Fixed `project-nvim` command and keybinding
|
||||
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
|
||||
|
||||
[Soliprem](https://github.com/Soliprem)
|
||||
[Soliprem](https://github.com/Soliprem):
|
||||
|
||||
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
||||
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
||||
ccc
|
||||
|
||||
[Bloxx12](https://github.com/Bloxx12):
|
||||
|
||||
- Fix internal breakage in `elixir-tools` setup.
|
||||
|
|
17
flake.lock
generated
17
flake.lock
generated
|
@ -1149,6 +1149,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-nvim-metals": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1728033462,
|
||||
"narHash": "sha256-XqOkZ/5eex1mrNUf6vrJjDjibBbb0bSMYSciKAoVD0A=",
|
||||
"owner": "ksonj",
|
||||
"repo": "nvim-metals",
|
||||
"rev": "4d86c32f6c028de197e28dab0f6a0250c0d1c16a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ksonj",
|
||||
"repo": "nvim-metals",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-nvim-navbuddy": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1863,6 +1879,7 @@
|
|||
"plugin-nvim-docs-view": "plugin-nvim-docs-view",
|
||||
"plugin-nvim-lightbulb": "plugin-nvim-lightbulb",
|
||||
"plugin-nvim-lspconfig": "plugin-nvim-lspconfig",
|
||||
"plugin-nvim-metals": "plugin-nvim-metals",
|
||||
"plugin-nvim-navbuddy": "plugin-nvim-navbuddy",
|
||||
"plugin-nvim-navic": "plugin-nvim-navic",
|
||||
"plugin-nvim-neoclip": "plugin-nvim-neoclip",
|
||||
|
|
|
@ -206,6 +206,11 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-nvim-metals = {
|
||||
url = "github:ksonj/nvim-metals";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Copying/Registers
|
||||
plugin-registers = {
|
||||
url = "github:tversteeg/registers.nvim";
|
||||
|
|
|
@ -19,6 +19,7 @@ in {
|
|||
./python.nix
|
||||
./r.nix
|
||||
./rust.nix
|
||||
./scala.nix
|
||||
./sql.nix
|
||||
./svelte.nix
|
||||
./tailwind.nix
|
||||
|
|
141
modules/plugins/languages/scala.nix
Normal file
141
modules/plugins/languages/scala.nix
Normal file
|
@ -0,0 +1,141 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) types optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
mkBinding = binding: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${binding.action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
|
||||
|
||||
listCommandsBinding = {
|
||||
value = cfg.lsp.extraMappings.listCommands;
|
||||
description = "List Metals commands";
|
||||
action =
|
||||
if config.vim.telescope.enable
|
||||
then ''require("telescope").extensions.metals.commands()''
|
||||
else ''require("metals").commands()'';
|
||||
};
|
||||
|
||||
cfg = config.vim.languages.scala;
|
||||
|
||||
usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable;
|
||||
usingLualine = config.vim.statusline.lualine.enable;
|
||||
in {
|
||||
options.vim.languages.scala = {
|
||||
enable = mkEnableOption "Scala language support";
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "scala";
|
||||
};
|
||||
lsp = {
|
||||
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.metals;
|
||||
description = ''
|
||||
metals package to use
|
||||
'';
|
||||
};
|
||||
extraMappings = {
|
||||
listCommands = mkMappingOption "List Metals commands" "<leader>lc";
|
||||
};
|
||||
};
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
description = "Scala Debug Adapter support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
};
|
||||
config = mkOption {
|
||||
description = "Lua configuration for dap";
|
||||
type = types.str;
|
||||
default = ''
|
||||
dap.configurations.scala = {
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "RunOrTest",
|
||||
metals = {
|
||||
runType = "runOrTestFile",
|
||||
--args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example
|
||||
},
|
||||
},
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "Test Target",
|
||||
metals = {
|
||||
runType = "testTarget",
|
||||
},
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable (
|
||||
mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-metals"];
|
||||
luaConfigRC.nvim-metals = entryAfter ["lsp-setup"] ''
|
||||
-- Scala nvim-metals config
|
||||
local metals_caps = capabilities -- from lsp-setup
|
||||
|
||||
local attach_metals_keymaps = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr) -- from lsp-setup
|
||||
${mkBinding listCommandsBinding}
|
||||
end
|
||||
|
||||
metals_config = require('metals').bare_config()
|
||||
${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"}
|
||||
|
||||
metals_config.capabilities = metals_caps
|
||||
metals_config.on_attach = function(client, bufnr)
|
||||
${optionalString usingDap "require('metals').setup_dap()"}
|
||||
attach_metals_keymaps(client, bufnr)
|
||||
end
|
||||
metals_config.settings = {
|
||||
metalsBinaryPath = "${cfg.lsp.package}/bin/metals",
|
||||
showImplicitArguments = true,
|
||||
showImplicitConversionsAndClasses = true,
|
||||
showInferredType = true,
|
||||
excludedPackages = {
|
||||
"akka.actor.typed.javadsl",
|
||||
"com.github.swagger.akka.javadsl"
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = {
|
||||
prefix = '⚠',
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
-- without doing this, autocommands that deal with filetypes prohibit messages from being shown
|
||||
vim.opt_global.shortmess:remove("F")
|
||||
|
||||
vim.cmd([[augroup lsp]])
|
||||
vim.cmd([[autocmd!]])
|
||||
vim.cmd([[autocmd FileType java,scala,sbt lua require('metals').initialize_or_attach(metals_config)]])
|
||||
vim.cmd([[augroup end]])
|
||||
'';
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
Loading…
Add table
Reference in a new issue