mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-30 23:54:50 +02:00
added rust-tools thanks to bob3000 (#544)
* added rust-tools * require_plugin has been removed
This commit is contained in:
parent
dbad645f90
commit
758798b6f9
7 changed files with 117 additions and 6 deletions
5
init.lua
5
init.lua
|
@ -35,7 +35,10 @@ if O.lang.lua.active then require('lsp.lua-ls') end
|
||||||
if O.lang.php.active then require('lsp.php-ls') end
|
if O.lang.php.active then require('lsp.php-ls') end
|
||||||
if O.lang.python.active then require('lsp.python-ls') end
|
if O.lang.python.active then require('lsp.python-ls') end
|
||||||
if O.lang.ruby.active then require('lsp.ruby-ls') end
|
if O.lang.ruby.active then require('lsp.ruby-ls') end
|
||||||
if O.lang.rust.active then require('lsp.rust-ls') end
|
if O.lang.rust.active then
|
||||||
|
require('lsp.rust-ls')
|
||||||
|
require('lv-rust-tools')
|
||||||
|
end
|
||||||
if O.lang.svelte.active then require('lsp.svelte-ls') end
|
if O.lang.svelte.active then require('lsp.svelte-ls') end
|
||||||
if O.lang.terraform.active then require('lsp.terraform-ls') end
|
if O.lang.terraform.active then require('lsp.terraform-ls') end
|
||||||
if O.lang.tailwindcss.active then require('lsp.tailwindcss-ls') end
|
if O.lang.tailwindcss.active then require('lsp.tailwindcss-ls') end
|
||||||
|
|
|
@ -163,7 +163,17 @@ O = {
|
||||||
vim = {active = false},
|
vim = {active = false},
|
||||||
yaml = {active = false},
|
yaml = {active = false},
|
||||||
terraform = {active = false},
|
terraform = {active = false},
|
||||||
rust = {active = false},
|
rust = {
|
||||||
|
active = false,
|
||||||
|
linter = '',
|
||||||
|
formatter = '',
|
||||||
|
autoformat = false,
|
||||||
|
diagnostics = {
|
||||||
|
virtual_text = {spacing = 0, prefix = ""},
|
||||||
|
signs = true,
|
||||||
|
underline = true
|
||||||
|
}
|
||||||
|
},
|
||||||
svelte = {active = false},
|
svelte = {active = false},
|
||||||
php = {active = false},
|
php = {active = false},
|
||||||
latex = {active = false},
|
latex = {active = false},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require'lspconfig'.rust_analyzer.setup{
|
-- the rust-tools plugin will configure this automatically
|
||||||
cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
|
--require'lspconfig'.rust_analyzer.setup{
|
||||||
on_attach = require'lsp'.common_on_attach
|
-- cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
|
||||||
}
|
-- on_attach = require'lsp'.common_on_attach
|
||||||
|
--}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ if O.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
|
||||||
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
|
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
|
||||||
if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end
|
if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end
|
||||||
|
|
||||||
|
local rust_format = {'BufWritePre', '*.rs', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
|
||||||
|
if O.lang.rust.autoformat then table.insert(auto_formatters, rust_format) end
|
||||||
|
|
||||||
utils.define_augroups({
|
utils.define_augroups({
|
||||||
_general_settings = {
|
_general_settings = {
|
||||||
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
|
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
|
||||||
|
|
85
lua/lv-rust-tools/init.lua
Normal file
85
lua/lv-rust-tools/init.lua
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
local opts = {
|
||||||
|
tools = { -- rust-tools options
|
||||||
|
-- automatically set inlay hints (type hints)
|
||||||
|
-- There is an issue due to which the hints are not applied on the first
|
||||||
|
-- opened file. For now, write to the file to trigger a reapplication of
|
||||||
|
-- the hints or just run :RustSetInlayHints.
|
||||||
|
-- default: true
|
||||||
|
autoSetHints = true,
|
||||||
|
|
||||||
|
-- whether to show hover actions inside the hover window
|
||||||
|
-- this overrides the default hover handler
|
||||||
|
-- default: true
|
||||||
|
hover_with_actions = true,
|
||||||
|
|
||||||
|
runnables = {
|
||||||
|
-- whether to use telescope for selection menu or not
|
||||||
|
-- default: true
|
||||||
|
use_telescope = true
|
||||||
|
|
||||||
|
-- rest of the opts are forwarded to telescope
|
||||||
|
},
|
||||||
|
|
||||||
|
inlay_hints = {
|
||||||
|
-- wheter to show parameter hints with the inlay hints or not
|
||||||
|
-- default: true
|
||||||
|
show_parameter_hints = true,
|
||||||
|
|
||||||
|
-- prefix for parameter hints
|
||||||
|
-- default: "<-"
|
||||||
|
parameter_hints_prefix = "<-",
|
||||||
|
|
||||||
|
-- prefix for all the other hints (type, chaining)
|
||||||
|
-- default: "=>"
|
||||||
|
other_hints_prefix = "=>",
|
||||||
|
|
||||||
|
-- whether to align to the lenght of the longest line in the file
|
||||||
|
max_len_align = false,
|
||||||
|
|
||||||
|
-- padding from the left if max_len_align is true
|
||||||
|
max_len_align_padding = 1,
|
||||||
|
|
||||||
|
-- whether to align to the extreme right or not
|
||||||
|
right_align = false,
|
||||||
|
|
||||||
|
-- padding from the right if right_align is true
|
||||||
|
right_align_padding = 7,
|
||||||
|
},
|
||||||
|
|
||||||
|
hover_actions = {
|
||||||
|
-- the border that is used for the hover window
|
||||||
|
-- see vim.api.nvim_open_win()
|
||||||
|
border = {
|
||||||
|
{"╭", "FloatBorder"},
|
||||||
|
{"─", "FloatBorder"},
|
||||||
|
{"╮", "FloatBorder"},
|
||||||
|
{"│", "FloatBorder"},
|
||||||
|
{"╯", "FloatBorder"},
|
||||||
|
{"─", "FloatBorder"},
|
||||||
|
{"╰", "FloatBorder"},
|
||||||
|
{"│", "FloatBorder"}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- all the opts to send to nvim-lspconfig
|
||||||
|
-- these override the defaults set by rust-tools.nvim
|
||||||
|
-- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
|
||||||
|
server = {
|
||||||
|
cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
|
||||||
|
on_attach = require'lsp'.common_on_attach
|
||||||
|
}, -- rust-analyser options
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
require('rust-tools').setup(opts)
|
||||||
|
|
||||||
|
vim.api.nvim_exec(
|
||||||
|
[[
|
||||||
|
autocmd Filetype rust nnoremap <leader>lm <Cmd>RustExpandMacro<CR>
|
||||||
|
autocmd Filetype rust nnoremap <leader>lH <Cmd>RustToggleInlayHints<CR>
|
||||||
|
autocmd Filetype rust nnoremap <leader>le <Cmd>RustRunnables<CR>
|
||||||
|
autocmd Filetype rust nnoremap <leader>lh <Cmd>RustHoverActions<CR>
|
||||||
|
]], true)
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,12 @@ return require("packer").startup(function(use)
|
||||||
requires = 'nvim-lua/plenary.nvim'
|
requires = 'nvim-lua/plenary.nvim'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
-- Rust tools
|
||||||
|
-- TODO: use lazy loading maybe?
|
||||||
|
use {
|
||||||
|
"simrat39/rust-tools.nvim",
|
||||||
|
disable = not O.lang.rust.active
|
||||||
|
}
|
||||||
-- Lazygit
|
-- Lazygit
|
||||||
use {
|
use {
|
||||||
"kdheepak/lazygit.nvim",
|
"kdheepak/lazygit.nvim",
|
||||||
|
|
|
@ -80,6 +80,9 @@ O.lang.ruby.autoformat = true
|
||||||
|
|
||||||
-- go
|
-- go
|
||||||
O.lang.go.autoformat = true
|
O.lang.go.autoformat = true
|
||||||
|
|
||||||
|
-- rust
|
||||||
|
O.lang.rust.autoformat = true
|
||||||
-- create custom autocommand field (This would be easy with lua)
|
-- create custom autocommand field (This would be easy with lua)
|
||||||
|
|
||||||
-- Turn off relative_numbers
|
-- Turn off relative_numbers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue