-
Notifications
You must be signed in to change notification settings - Fork 0
1. Installation
This guide covers installing and configuring scala-hints.nvim for Neovim.
| Requirement | Version | Purpose |
|---|---|---|
| Neovim | 0.11+ | Core editor with LSP and diagnostic support |
| Metals | Latest | Scala LSP server for type verification |
| nvim-treesitter | Latest | Scala parser for AST matching |
| plenary.nvim | Latest | Async utilities |
" Check Neovim version
:version
" Should show v0.11.0 or higher
" Check if Treesitter Scala parser is installed
:TSInstallInfo
" Should show scala installed
" Check if Metals is running
:LspInfo
" Should show metals attached to Scala buffers{
'olisikh/scala-hints.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'scalameta/nvim-metals',
},
opts = {}, -- uses default configuration
}With custom configuration:
{
'olisikh/scala-hints.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'scalameta/nvim-metals',
},
opts = {
logging = {
enabled = true,
level = 'INFO',
},
diagnostics = {
default_severity = 'HINT',
overrides = {
['zio/zio_die'] = 'WARN',
},
},
},
}use {
'olisikh/scala-hints.nvim',
requires = {
'nvim-lua/plenary.nvim',
'scalameta/nvim-metals',
},
config = function()
require('scala-hints').setup({
logging = {
enabled = true,
level = 'INFO',
},
})
end,
}" Required dependencies
Plug 'nvim-lua/plenary.nvim'
Plug 'scalameta/nvim-metals'
" scala-hints.nvim
Plug 'olisikh/scala-hints.nvim'Then add to your init.vim or a separate Lua config file:
" In init.vim (if using Vimscript)
lua require('scala-hints').setup()
" Or in lua/config/scala-hints.lua
require('scala-hints').setup({
logging = { enabled = true, level = 'INFO' },
}):TSInstall scalascala-hints.nvim requires Metals to be running and attached to your Scala buffers. If you're using nvim-metals, ensure it's properly configured:
local metals_config = require('metals').bare_config()
metals_config.settings = {
showImplicitArguments = true,
showImplicitConversionsAndClasses = true,
showInferredType = true,
}
-- Autocommand to start Metals
vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt" },
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }),
})- Open a Scala file in a project with Metals configured
- Wait for Metals to initialize (check
:LspInfo) - Write some code that matches a pattern, e.g.:
// This should trigger a hint:
ZIO.succeed(())- Check for diagnostics with
:lua vim.diagnostic.get(0)
require('scala-hints').setup({
-- Logging configuration
logging = {
enabled = false, -- Enable file logging for debugging
level = 'INFO', -- Log level: debug|info|warn|error
},
-- Type definition LSP settings
type_definition = {
timeouts_ms = { 400, 1000, 2000 }, -- Retry schedule (ms)
max_inflight = 4, -- Max concurrent requests per buffer
},
-- Diagnostic settings
diagnostics = {
default_severity = 'HINT', -- Default: HINT, INFO, WARN, ERROR, OFF
overrides = {
-- Disable specific patterns
['zio/zip_left_value'] = 'OFF',
['zio/zip_right_operator'] = 'OFF',
-- Elevate severity for important patterns
['zio/zio_die'] = 'WARN',
},
excluded_libs = {}, -- Exclude libraries: { "zio", "cats-effect", "cats" }
},
-- Code action settings
actions = {
excluded_libs = {}, -- Exclude libraries from code actions
},
})Symptoms: No hints shown even on matching patterns.
Solutions:
-
Metals not ready: Wait for
MetalsReadyorMetalsInitializedevent:echo g:metals_status
-
Treesitter parser missing:
:TSInstall scala :TSInstallInfo
-
Check if plugin is loaded:
:lua print(vim.inspect(package.loaded['scala-hints']))
-
Enable logging to see what's happening:
require('scala-hints').setup({ logging = { enabled = true, level = 'DEBUG' }, })
Cause: Neovim's undo doesn't trigger a diagnostic refresh.
Solution: Reopen the buffer or save the file to force a refresh.
Symptoms: Hints appear on non-ZIO/Cats-Effect code.
Cause: Some patterns skip Metals type verification for performance.
Solution: Check AGENTS.md for LSP-dependent patterns. Report issues with a minimal reproduction.
Symptoms: Errors about textDocument/typeDefinition timing out.
Solutions:
-
Increase timeout values:
require('scala-hints').setup({ type_definition = { timeouts_ms = { 800, 2000, 4000 }, }, })
-
Reduce concurrent requests:
require('scala-hints').setup({ type_definition = { max_inflight = 2, }, })
Solutions:
-
Exclude libraries you don't use:
require('scala-hints').setup({ diagnostics = { excluded_libs = { "cats" } }, actions = { excluded_libs = { "cats" } }, })
-
Disable specific patterns:
require('scala-hints').setup({ diagnostics = { overrides = { ['zio/zio_type'] = 'OFF', ['zio/zlayer_type'] = 'OFF', }, }, })
Cause: lazy.nvim lazy-loads plugins by default.
Solution: Ensure dependencies are explicitly declared:
{
'olisikh/scala-hints.nvim',
lazy = false, -- Load immediately (optional)
dependencies = {
'nvim-lua/plenary.nvim',
'scalameta/nvim-metals',
},
opts = {},
}- Issues: GitHub Issues
- Architecture: See AGENTS.md for technical details
- Pattern Catalog: See README.md for all supported patterns