feat(nvim): update rust-tools and haskell-tools
This commit is contained in:
parent
8a386796eb
commit
ffa2a6b892
|
@ -8,7 +8,7 @@
|
|||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "7e5a85c186027cab1e825d018f07c350177077fc" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "d927caa075df63bf301d92f874efb72fd22fd3b4" },
|
||||
"haskell-tools.nvim": { "branch": "1.x.x", "commit": "0bf0c887eeb7febe2199b7638befb4138d293111" },
|
||||
"haskell-tools.nvim": { "branch": "2.x.x", "commit": "fd7c33cc3e893a12c1d90aca9ff7ede7d01f003d" },
|
||||
"kanagawa.nvim": { "branch": "master", "commit": "0a24e504a3a278849ad0aef31cd6dd24c73ca3db" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" },
|
||||
|
@ -22,9 +22,10 @@
|
|||
"nvim-dap-ui": { "branch": "master", "commit": "85b16ac2309d85c88577cd8ee1733ce52be8227e" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "17b943e7c5cc2b2db3ac7b5720fbd42e75a00d8d" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "bc11ee2498de2310de5776477dd9dce65d03b464" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" },
|
||||
"rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
local map = require("utility").curried_map
|
||||
local map = require("utility").curried_keymap
|
||||
local n, t = map 'n', map 't'
|
||||
|
||||
|
||||
n "<leader>mn" ":Explore ~/.config/nvim/<cr>" "Meta: open Neovim config"
|
||||
|
||||
n "<Leader>ex" ":Explore<CR>" "Netrw: open"
|
||||
n "<Leader>hl" ":nohl<CR>" "Hide highlights"
|
||||
|
||||
n "j" "gj" "Move: down by line"
|
||||
|
@ -18,4 +21,9 @@ n "<C-j>" "<C-w>j" "Window: move down"
|
|||
n "<C-k>" "<C-w>k" "Window: move up"
|
||||
n "<C-l>" "<C-w>l" "Window: move right"
|
||||
|
||||
n "<Leader>e" ":Explore<CR>" "Netrw: open"
|
||||
-- Diagnostic
|
||||
n "<leader>de" (vim.diagnostic.open_float) "Diagnostic: open float"
|
||||
n "[d" (vim.diagnostic.goto_prev) "Previous diagnostic message"
|
||||
n "]d" (vim.diagnostic.goto_next) "Next diagnostic message"
|
||||
n "<leader>dl" (vim.diagnostic.setloclist) "Diagnostic: list messages"
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ return {
|
|||
config = function()
|
||||
local telescope = require "telescope"
|
||||
local builtin = require "telescope.builtin"
|
||||
|
||||
telescope.setup({
|
||||
extensions = {
|
||||
fzf = {
|
||||
|
@ -47,8 +46,7 @@ return {
|
|||
}
|
||||
})
|
||||
telescope.load_extension("fzf")
|
||||
|
||||
local nmap = U.curried_map 'n'
|
||||
local nmap = U.curried_keymap 'n'
|
||||
nmap "<leader>ff" (builtin.find_files) "Telescope: find files"
|
||||
nmap "<leader>fb" (builtin.buffers) "Telescope: find buffers"
|
||||
nmap "<leader>fg" (builtin.live_grep) "Telescope: grep content"
|
||||
|
@ -56,6 +54,16 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 300
|
||||
end,
|
||||
opts = {}
|
||||
},
|
||||
|
||||
-- File tree
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
|
@ -108,27 +116,27 @@ return {
|
|||
sync_install = false,
|
||||
ensure_installed = {
|
||||
-- nvim
|
||||
"vim", "vimdoc", "lua", "fennel",
|
||||
"vim", "vimdoc", "lua",
|
||||
-- misc
|
||||
"comment", "dockerfile", "json", "yaml", "toml", "regex",
|
||||
-- git
|
||||
"gitcommit", "gitignore", "diff",
|
||||
-- shell
|
||||
"bash", -- "fish", "nu",
|
||||
"bash",
|
||||
-- markdown
|
||||
"markdown", "markdown_inline",
|
||||
-- python
|
||||
"python",
|
||||
-- rust
|
||||
"rust", "toml",
|
||||
"rust",
|
||||
-- webdev
|
||||
"html", "css", "scss", "javascript", "jsdoc", "typescript", "tsx", "astro", "svelte", "vue",
|
||||
"html", "css", "scss", "javascript", "jsdoc", "typescript", "tsx", "astro", "svelte",
|
||||
-- haskell
|
||||
"haskell",
|
||||
-- nix
|
||||
"nix",
|
||||
-- literate
|
||||
"latex", "bibtex", -- "typst",
|
||||
"latex", "bibtex",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
@ -268,8 +276,8 @@ return {
|
|||
-- Tools for Haskell
|
||||
U.plugin("plugins.haskell-tools") {
|
||||
"mrcjkb/haskell-tools.nvim",
|
||||
branch = "1.x.x",
|
||||
ft = "haskell",
|
||||
branch = "2.x.x",
|
||||
ft = {"haskell", "lhaskell", "cabal", "cabalproject"},
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
|
|
|
@ -1,40 +1,35 @@
|
|||
local nmap = require("utility").curried_keymap('n')
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
local ht = require('haskell-tools')
|
||||
local def_opts = { noremap = true, silent = true, }
|
||||
|
||||
ht.start_or_attach {
|
||||
function M.init()
|
||||
vim.g.haskell_tools = {
|
||||
hls = {
|
||||
on_attach = function(_, bufnr)
|
||||
local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, })
|
||||
-- haskell-language-server relies heavily on codeLenses,
|
||||
-- so auto-refresh (see advanced configuration) is enabled by default
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.codelens.run, opts)
|
||||
vim.keymap.set('n', '<space>hs', ht.hoogle.hoogle_signature, opts)
|
||||
vim.keymap.set('n', '<space>ea', ht.lsp.buf_eval_all, opts)
|
||||
end,
|
||||
},
|
||||
on_attach = function(_, buffer, ht)
|
||||
nmap "<leader>hs" (ht.hoogle.hoogle_signature) {"Hoogle: search", buffer}
|
||||
nmap "<leader>ha" (ht.lsp.buf_eval_all) {"Haskell: eval all", buffer}
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
-- Suggested keymaps that do not depend on haskell-language-server:
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
-- set buffer = bufnr in ftplugin/haskell.lua
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
function M.config()
|
||||
local ht = require "haskell-tools"
|
||||
local buffer = vim.api.nvim_get_current_buf()
|
||||
|
||||
-- Toggle a GHCi repl for the current package
|
||||
vim.keymap.set('n', '<leader>rr', ht.repl.toggle, opts)
|
||||
-- Toggle a GHCi repl for the current buffer
|
||||
vim.keymap.set('n', '<leader>rf', function()
|
||||
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
|
||||
end, def_opts)
|
||||
vim.keymap.set('n', '<leader>rq', ht.repl.quit, opts)
|
||||
local function repl_file()
|
||||
local name = vim.api.nvim_buf_get_name(0)
|
||||
ht.repl.toggle(name)
|
||||
end
|
||||
|
||||
nmap "<leader>rr" (ht.repl.toggle) {"Repl: Toggle GHCi for the current package", buffer}
|
||||
nmap "<leader>rf" (repl_file) "Repl: Toggle GHCi for the current buffer"
|
||||
nmap "<leader>rq" (ht.repl.quit) {"Repl: Quit", buffer}
|
||||
|
||||
-- Detect nvim-dap launch configurations
|
||||
-- (requires nvim-dap and haskell-debug-adapter)
|
||||
-- ht.dap.discover_configurations(bufnr)
|
||||
return 1
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
return M
|
||||
|
|
|
@ -2,13 +2,6 @@ local M = {}
|
|||
|
||||
|
||||
function M.config()
|
||||
-- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
local nmap = require("utility").curried_keymap('n')
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
local rt = require "rust-tools"
|
||||
local tools = require "rust-tools"
|
||||
local mason = require "mason-registry"
|
||||
local capabilities = require "cmp_nvim_lsp"
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local lsp_root = mason.get_package("codelldb"):get_install_path() .. "/extension/"
|
||||
local lsp_path = lsp_root .. "adapter/codelldb"
|
||||
|
@ -12,17 +13,15 @@ function M.config()
|
|||
local opts = {
|
||||
server = {
|
||||
standalone = true,
|
||||
-- capabilities = capabilities,
|
||||
on_attach = function(client, bufnr)
|
||||
local buf_opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', "<C-b>", rt.hover_actions.hover_actions, buf_opts)
|
||||
vim.keymap.set('n', "<Leader>a", rt.code_action_group.code_action_group, buf_opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, buf_opts)
|
||||
capabilities = capabilities,
|
||||
on_attach = function(_, bufnr)
|
||||
nmap "<C-b>" (tools.hover_actions.hover_actions) {buffer=bufnr}
|
||||
nmap "<Leader>a" (tools.code_action_group.code_action_group) {buffer=bufnr}
|
||||
end,
|
||||
["rust-analyzer"] = {
|
||||
cargo = { allFeatures = true },
|
||||
checkOnSave = {
|
||||
-- default: `cargo check`
|
||||
-- default = "cargo check",
|
||||
command = "clippy",
|
||||
allFeatures = true,
|
||||
}
|
||||
|
@ -33,7 +32,7 @@ function M.config()
|
|||
},
|
||||
}
|
||||
|
||||
rt.setup(opts)
|
||||
tools.setup(opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -13,20 +13,29 @@ function M.plugin(path)
|
|||
end
|
||||
end
|
||||
|
||||
---@class KeymapOpts
|
||||
---@field [1] string? Shorthand description
|
||||
---@field desc string? Description
|
||||
---@field [2] number|boolean? Shorthand buffer
|
||||
---@field buffer number|boolean? Buffer
|
||||
|
||||
---Wrapper around `vim.keymap.set`
|
||||
---@param modes string|string[]
|
||||
function M.curried_map(modes)
|
||||
function M.curried_keymap(modes)
|
||||
---@param lhs string
|
||||
return function(lhs)
|
||||
---@param rhs string|function
|
||||
return function(rhs)
|
||||
---@param opts string|table
|
||||
---@param opts string|KeymapOpts
|
||||
return function(opts)
|
||||
local supplied = type(opts)
|
||||
local options
|
||||
if supplied == "string" then
|
||||
options = vim.tbl_extend("force", def_opts, {desc=opts})
|
||||
else
|
||||
elseif supplied == "table" then
|
||||
opts.desc = opts[1] or opts.desc
|
||||
opts.buffer = opts[2] or opts.buffer
|
||||
opts[1], opts[2] = nil, nil
|
||||
options = vim.tbl_extend("force", def_opts, opts)
|
||||
end
|
||||
vim.keymap.set(modes, lhs, rhs, options)
|
||||
|
|
Loading…
Reference in a new issue