Skip to content

Commit 2e64f5d

Browse files
committed
feat: enable custom rust settings
1 parent 2f24992 commit 2e64f5d

4 files changed

Lines changed: 44 additions & 4 deletions

File tree

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazy_lua_modules/haskell-tools-nvim.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ require("lze").load({
66
require("haskell-tools")
77
require("telescope").load_extension("ht")
88
vim.cmd("doautocmd FileType haskell")
9+
local ht = require("haskell-tools")
10+
local bufnr = vim.api.nvim_get_current_buf()
11+
local opts = { noremap = true, silent = true, buffer = bufnr }
12+
-- haskell-language-server relies heavily on codeLenses,
13+
-- so auto-refresh (see advanced configuration) is enabled by default
14+
vim.keymap.set("n", "<space>cl", vim.lsp.codelens.run, opts)
15+
-- Hoogle search for the type signature of the definition under the cursor
16+
vim.keymap.set("n", "<space>hs", ht.hoogle.hoogle_signature, opts)
17+
-- Evaluate all code snippets
18+
vim.keymap.set("n", "<space>ea", ht.lsp.buf_eval_all, opts)
19+
-- Toggle a GHCi repl for the current package
20+
vim.keymap.set("n", "<leader>rr", ht.repl.toggle, opts)
21+
-- Toggle a GHCi repl for the current buffer
22+
vim.keymap.set("n", "<leader>rf", function()
23+
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
24+
end, opts)
25+
vim.keymap.set("n", "<leader>rq", ht.repl.quit, opts)
926
end,
1027
})

lazy_lua_modules/rustaceanvim.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,30 @@ require("lze").load({
77
-- filetypes = { "rust" },
88
-- root_markers = { ".git", "Cargo.lock" },
99
-- }
10+
local root = vim.fn.getcwd()
11+
local git_root = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
12+
if vim.v.shell_error == 0 and git_root and #git_root > 0 then
13+
root = git_root
14+
end
15+
16+
-- load per-project nvim_config.lua if it exists
17+
local config_path = root .. "/nvim_config.lua"
18+
local project_settings = nil
19+
20+
if vim.fn.filereadable(config_path) == 1 then
21+
local ok, cfg = pcall(dofile, config_path)
22+
if ok and type(cfg) == "table" then
23+
project_settings = cfg
24+
else
25+
vim.notify("Failed to load project nvim_config.lua", vim.log.levels.WARN)
26+
end
27+
end
28+
1029
vim.g.rustaceanvim = {
1130
client = { server_capabilities = { inlayHintProvider = true } },
31+
server = {
32+
settings = project_settings or {},
33+
},
1234
tools = {
1335
autoSetHints = true,
1436
runnables = { use_telescope = true },

required_lua_modules/lsp.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
140140
capabilities.textDocument.completion.completionItem.snippetSupport = true
141141

142142
require("lspconfig").jsonls.setup({
143-
cmd = { "vscode-json-languageserver", "--stdio" },
143+
cmd = { "vscode-json-language-server", "--stdio" },
144144
capabilities = capabilities,
145145
})
146146

@@ -290,6 +290,7 @@ require("conform").setup({
290290
typst = { "prettypst" },
291291
html = { "prettierd" },
292292
ocaml = { "ocamlformat" },
293+
haskell = { "fourmolu" },
293294
},
294295
-- Command to toggle format-on-save
295296
-- https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-format-on-save

0 commit comments

Comments
 (0)