wip: feat(nvim/rust-tools): begin migration
wip: feat(nvim/rust-tools): begin migration feat(nvim/dev-icons): enable feat(nvim/nerdtree): removed feat(nvim): removed coc feat(nvim/cmp): connect rust-tools feat(nvim/dap): setup lldb feat(nvim/cmp): icons feat(nvim/dap): icons feat(nvim/rust): load crates plugin feat(nvim): switch rust-tools to rustaceanvim feat(nvim): enable inlay hints feat(nvim): cmdline completions style: nix run sys#luaformatter -- home/nvim/*.lua -i feat(nvim/nix): break once neovim hits 0.10.0 wip: feat(nvim/rust-tools): begin migration feat(nvim): removed coc
This commit is contained in:
parent
cdb1cbd040
commit
8cd1e08ecf
93
completion.lua
Normal file
93
completion.lua
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
|
-- Set completeopt to have a better completion experience
|
||||||
|
-- :help completeopt
|
||||||
|
-- menuone: popup even when there's only one match
|
||||||
|
-- noinsert: Do not insert text until a selection is made
|
||||||
|
-- noselect: Do not select, force to select one from the menu
|
||||||
|
-- shortness: avoid showing extra messages when using completion
|
||||||
|
-- updatetime: set updatetime for CursorHold
|
||||||
|
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
|
||||||
|
vim.opt.shortmess = vim.opt.shortmess + {c = true}
|
||||||
|
vim.api.nvim_set_option('updatetime', 300)
|
||||||
|
|
||||||
|
-- Fixed column for diagnostics to appear
|
||||||
|
-- Show autodiagnostic popup on cursor hover_range
|
||||||
|
-- Goto previous / next diagnostic warning / error
|
||||||
|
-- Show inlay_hints more frequently
|
||||||
|
vim.cmd([[
|
||||||
|
set signcolumn=yes
|
||||||
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
||||||
|
]])
|
||||||
|
|
||||||
|
vim.opt.spell = true
|
||||||
|
vim.opt.spelllang = {'en_us'}
|
||||||
|
vim.lsp.handlers["textDocument/publishDiagnostics"] =
|
||||||
|
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics,
|
||||||
|
{virtual_text = true})
|
||||||
|
-- Completion Plugin Setup
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
cmp.setup({
|
||||||
|
-- Enable LSP snippets
|
||||||
|
snippet = {expand = function(args) vim.fn["vsnip#anonymous"](args.body) end},
|
||||||
|
-- <C> = CTRL
|
||||||
|
-- <S> = SHIFT
|
||||||
|
mapping = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
-- Add tab support
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
-- Installed sources:
|
||||||
|
sources = {
|
||||||
|
{name = 'path'}, -- file paths
|
||||||
|
{name = 'nvim_lsp', keyword_length = 3}, -- from language server
|
||||||
|
{name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
|
||||||
|
{name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
|
||||||
|
{name = 'buffer', keyword_length = 2}, -- source current buffer
|
||||||
|
{name = 'calc'}, -- source for math calculation
|
||||||
|
{
|
||||||
|
name = 'spell',
|
||||||
|
option = {
|
||||||
|
keep_all_entries = false,
|
||||||
|
enable_in_context = function() return true end
|
||||||
|
}
|
||||||
|
}, {name = 'conventionalcommits', keyword_length = 1}, {name = 'crates'}
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered()
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = {'menu', 'abbr' --[[ 'kind' ]] },
|
||||||
|
format = function(entry, item)
|
||||||
|
local menu_icon = {
|
||||||
|
nvim_lsp = 'λ',
|
||||||
|
vsnip = '⋗',
|
||||||
|
buffer = '',
|
||||||
|
path = '',
|
||||||
|
spell = '¶',
|
||||||
|
calc = '√',
|
||||||
|
crates = ''
|
||||||
|
}
|
||||||
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
if entry.source.name == "calc" then item.kind = "Math" end
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
}
|
||||||
|
})
|
||||||
|
cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}})
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({{name = 'path'}}, {
|
||||||
|
{name = 'cmdline', option = {ignore_cmds = {'Man', '!'}}}
|
||||||
|
})
|
||||||
|
})
|
53
default.nix
53
default.nix
@ -40,29 +40,32 @@ in
|
|||||||
# vim-grammarous
|
# vim-grammarous
|
||||||
markdown-preview-nvim
|
markdown-preview-nvim
|
||||||
rainbow
|
rainbow
|
||||||
nerdtree
|
nvim-web-devicons
|
||||||
nerdtree-git-plugin
|
|
||||||
fzf-vim
|
fzf-vim
|
||||||
coc-sh
|
|
||||||
coc-nvim
|
|
||||||
coc-rust-analyzer
|
|
||||||
coc-json
|
|
||||||
coc-yaml
|
|
||||||
coc-tsserver
|
|
||||||
coc-prettier
|
|
||||||
coc-pyright
|
|
||||||
coc-diagnostic
|
|
||||||
vimtex
|
|
||||||
coc-vimtex
|
|
||||||
coc-html
|
|
||||||
coc-go
|
|
||||||
coc-spell-checker
|
|
||||||
editorconfig-nvim
|
editorconfig-nvim
|
||||||
|
vim-vsnip
|
||||||
# tmuxline-vim
|
# tmuxline-vim
|
||||||
nvim-dap
|
nvim-dap
|
||||||
nvim-dap-ui
|
nvim-dap-ui
|
||||||
nvim-notify
|
nvim-notify
|
||||||
rust-tools-nvim
|
nvim-cmp
|
||||||
|
cmp-nvim-lsp
|
||||||
|
cmp-nvim-lua
|
||||||
|
cmp-buffer
|
||||||
|
cmp-path
|
||||||
|
cmp-spell
|
||||||
|
cmp-vsnip
|
||||||
|
cmp-conventionalcommits
|
||||||
|
cmp-calc
|
||||||
|
cmp-cmdline
|
||||||
|
rustaceanvim
|
||||||
|
(if config.programs.neovim.package.version == "0.10.0" then throw "lsp-inlayhints-nvim may be removed" else lsp-inlayhints-nvim) # https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7620822
|
||||||
|
cmp-conventionalcommits
|
||||||
|
cmp-calc
|
||||||
|
cmp-cmdline
|
||||||
|
rustaceanvim
|
||||||
|
(if config.programs.neovim.package.version == "0.10.0" then throw "lsp-inlayhints-nvim may be removed" else lsp-inlayhints-nvim) # https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7620822
|
||||||
|
plenary-nvim
|
||||||
crates-nvim
|
crates-nvim
|
||||||
nvim-lspconfig
|
nvim-lspconfig
|
||||||
telescope-nvim
|
telescope-nvim
|
||||||
@ -76,11 +79,19 @@ in
|
|||||||
lldb = pkgs.lldb;
|
lldb = pkgs.lldb;
|
||||||
rust_analyzer = rust-analyzer;
|
rust_analyzer = rust-analyzer;
|
||||||
};
|
};
|
||||||
|
pathsLua = pkgs.writeTextFile {
|
||||||
|
name = "nvim-deps.lua";
|
||||||
|
text = ''
|
||||||
|
return {
|
||||||
|
${concatStringsSep ",\n " (mapAttrsToList (name: path: ''${name}_path = "${path}"'') paths)}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
confDir = lib.sourceFilesBySuffices ./. [ "lua" "vim" ];
|
confDir = lib.sourceFilesBySuffices ./. [ "lua" "vim" ];
|
||||||
in
|
in
|
||||||
with lib; ''
|
with lib; ''
|
||||||
vim.cmd [[source ${confDir}/init.vim]]
|
vim.cmd [[source ${confDir}/init.vim]]
|
||||||
${concatStringsSep "\n" (mapAttrsToList (name: path: ''${name}_path = "${path}"'') paths)}
|
package.path = package.path .. ";${confDir}/?.lua;${pathsLua};"
|
||||||
dofile("${confDir}/init.lua")
|
dofile("${confDir}/init.lua")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@ -186,9 +197,9 @@ in
|
|||||||
sdk = [ rust-sdk ];
|
sdk = [ rust-sdk ];
|
||||||
};
|
};
|
||||||
imports.group.enable = true;
|
imports.group.enable = true;
|
||||||
# inlayHints = {
|
inlayHints = {
|
||||||
# closureReturnTypeHints.enable = false;
|
closureReturnTypeHints.enable = false;
|
||||||
# };
|
};
|
||||||
highlightRelated = {
|
highlightRelated = {
|
||||||
yieldPoints.enable = true;
|
yieldPoints.enable = true;
|
||||||
references.enable = true;
|
references.enable = true;
|
||||||
|
77
init.lua
77
init.lua
@ -1,3 +1,4 @@
|
|||||||
|
local deps = require("nvim-deps")
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
vim.notify = require("notify")
|
vim.notify = require("notify")
|
||||||
vim.notify.setup({background_colour = "#000000"})
|
vim.notify.setup({background_colour = "#000000"})
|
||||||
@ -44,33 +45,9 @@ neogit.setup({
|
|||||||
local dap, dapui = require("dap"), require("dapui")
|
local dap, dapui = require("dap"), require("dapui")
|
||||||
dap.adapters.lldb = {
|
dap.adapters.lldb = {
|
||||||
type = "executable",
|
type = "executable",
|
||||||
command = lldb_path .. "/bin/lldb-vscode",
|
command = deps.lldb_path .. "/bin/lldb-vscode",
|
||||||
name = "lldb"
|
name = "lldb"
|
||||||
}
|
}
|
||||||
local lldb = {
|
|
||||||
name = "Launch lldb",
|
|
||||||
type = "lldb", -- matches the adapter
|
|
||||||
request = "launch", -- could also attach to a currently running process
|
|
||||||
program = function()
|
|
||||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/",
|
|
||||||
"file")
|
|
||||||
end,
|
|
||||||
cwd = "$${workspaceFolder}",
|
|
||||||
stopOnEntry = false,
|
|
||||||
args = {},
|
|
||||||
console = internalConsole,
|
|
||||||
runInTerminal = true
|
|
||||||
}
|
|
||||||
|
|
||||||
dap.configurations.rust = {
|
|
||||||
lldb -- different debuggers or more configurations can be used here
|
|
||||||
}
|
|
||||||
--[[ local opts = {
|
|
||||||
dap = {
|
|
||||||
adapter = require("rust-tools.dap").get_codelldb_adapter("${pkgs.lldb}/bin/lldb-vscode", "${pkgs.lldb.lib}/lib/liblldb.so"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
require("rust-tools").setup { opts } ]]
|
|
||||||
local dap_breakpoint = {
|
local dap_breakpoint = {
|
||||||
error = {
|
error = {
|
||||||
text = "🟥",
|
text = "🟥",
|
||||||
@ -79,19 +56,22 @@ local dap_breakpoint = {
|
|||||||
numhl = ""
|
numhl = ""
|
||||||
},
|
},
|
||||||
rejected = {
|
rejected = {
|
||||||
text = "",
|
text = "❗",
|
||||||
texthl = "LspDiagnosticsSignHint",
|
texthl = "LspDiagnosticsSignHint",
|
||||||
linehl = "",
|
linehl = "",
|
||||||
numhl = ""
|
numhl = ""
|
||||||
},
|
},
|
||||||
stopped = {
|
stopped = {
|
||||||
text = "⭐️",
|
text = "🛑",
|
||||||
texthl = "LspDiagnosticsSignInformation",
|
texthl = "LspDiagnosticsSignInformation",
|
||||||
linehl = "DiagnosticUnderlineInfo",
|
linehl = "DiagnosticUnderlineInfo",
|
||||||
numhl = "LspDiagnosticsSignInformation"
|
numhl = "LspDiagnosticsSignInformation"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>dk', function() dap.continue() end)
|
||||||
|
vim.keymap.set('n', '<leader>dl', function() dap.run_last() end)
|
||||||
|
vim.keymap.set('n', '<leader>b', function() dap.toggle_breakpoint() end)
|
||||||
vim.fn.sign_define("DapBreakpoint", dap_breakpoint.error)
|
vim.fn.sign_define("DapBreakpoint", dap_breakpoint.error)
|
||||||
vim.fn.sign_define("DapStopped", dap_breakpoint.stopped)
|
vim.fn.sign_define("DapStopped", dap_breakpoint.stopped)
|
||||||
vim.fn.sign_define("DapBreakpointRejected", dap_breakpoint.rejected)
|
vim.fn.sign_define("DapBreakpointRejected", dap_breakpoint.rejected)
|
||||||
@ -104,3 +84,46 @@ dap.listeners.after.event_initialized["dapui_config"] =
|
|||||||
dap.listeners.before.event_terminated["dapui_config"] =
|
dap.listeners.before.event_terminated["dapui_config"] =
|
||||||
function() dapui.close() end
|
function() dapui.close() end
|
||||||
dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end
|
dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end
|
||||||
|
|
||||||
|
-- Setup language servers.
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
-- Global mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
vim.keymap.set('n', '<leader>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', '<leader>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', {
|
||||||
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
|
callback = function(ev)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
|
-- Buffer local mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local opts = {buffer = ev.buf}
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap
|
||||||
|
.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||||
|
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder,
|
||||||
|
opts)
|
||||||
|
vim.keymap.set('n', '<leader>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set({'n', 'v'}, '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set('n', '<leader>f',
|
||||||
|
function() vim.lsp.buf.format {async = true} end, opts)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
require("lsp-inlayhints").setup()
|
||||||
|
require("completion")
|
||||||
|
62
init.vim
62
init.vim
@ -5,54 +5,6 @@ set hidden
|
|||||||
" disable mouse
|
" disable mouse
|
||||||
set mouse=
|
set mouse=
|
||||||
|
|
||||||
" GoTo code navigation.
|
|
||||||
nmap <silent> gd <Plug>(coc-definition)
|
|
||||||
nmap <silent> gy <Plug>(coc-type-definition)
|
|
||||||
nmap <silent> gi <Plug>(coc-implementation)
|
|
||||||
nmap <silent> gr <Plug>(coc-references)
|
|
||||||
|
|
||||||
|
|
||||||
" Rename
|
|
||||||
nmap <leader>rn <Plug>(coc-rename)
|
|
||||||
|
|
||||||
" Use K to show documentation in preview window.
|
|
||||||
nnoremap <silent> K :call ShowDocumentation()<CR>
|
|
||||||
|
|
||||||
nmap <leader>ac <Plug>(coc-codeaction)
|
|
||||||
nmap <leader>as <Plug>(coc-codeaction-cursor)
|
|
||||||
nmap <leader>cl <Plug>(coc-codelens-action)
|
|
||||||
|
|
||||||
nmap <silent> [G <Plug>(coc-diagnostic-next-error)
|
|
||||||
nmap <silent> ]G <Plug>(coc-diagnostic-prev-error)
|
|
||||||
|
|
||||||
nmap <silent> [g <Plug>(coc-diagnostic-next)
|
|
||||||
nmap <silent> ]g <Plug>(coc-diagnostic-prev)
|
|
||||||
|
|
||||||
" NERDTree config
|
|
||||||
" autocmd VimEnter * NERDTree
|
|
||||||
autocmd BufEnter * NERDTreeMirror
|
|
||||||
|
|
||||||
"CTRL-t to toggle tree view with CTRL-t
|
|
||||||
nmap <silent> <C-t> :NERDTreeToggle<CR>
|
|
||||||
"Set F2 to put the cursor to the nerdtree
|
|
||||||
nmap <silent> <F2> :NERDTreeFind<CR>
|
|
||||||
|
|
||||||
function! ShowDocumentation()
|
|
||||||
if CocAction('hasProvider', 'hover')
|
|
||||||
call CocActionAsync('doHover')
|
|
||||||
else
|
|
||||||
call feedkeys('K', 'in')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Highlight the symbol and its references when holding the cursor.
|
|
||||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
|
||||||
|
|
||||||
" Formatting selected code.
|
|
||||||
xmap <leader>f <Plug>(coc-format-selected)
|
|
||||||
nmap <leader>f <Plug>(coc-format-selected)
|
|
||||||
nmap <leader>F <Plug>(coc-format)
|
|
||||||
|
|
||||||
|
|
||||||
" " Copy to clipboard
|
" " Copy to clipboard
|
||||||
vnoremap <leader>y "+y
|
vnoremap <leader>y "+y
|
||||||
@ -76,9 +28,6 @@ map <leader>to :tabonly<cr>
|
|||||||
" Display line numbers
|
" Display line numbers
|
||||||
set number relativenumber
|
set number relativenumber
|
||||||
|
|
||||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
|
|
||||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
|
||||||
|
|
||||||
map <F3> :mksession! .nvim_session <cr> " Quick write session with F3
|
map <F3> :mksession! .nvim_session <cr> " Quick write session with F3
|
||||||
map <F4> :source .nvim_session <cr> " And load session with F4
|
map <F4> :source .nvim_session <cr> " And load session with F4
|
||||||
|
|
||||||
@ -95,17 +44,6 @@ let g:airline#extensions#tabline#enabled = 1
|
|||||||
let g:airline#extensions#tabline#show_tab_nr = 1
|
let g:airline#extensions#tabline#show_tab_nr = 1
|
||||||
let g:airline#extensions#tabline#tab_nr_type = 1
|
let g:airline#extensions#tabline#tab_nr_type = 1
|
||||||
|
|
||||||
" DAP
|
|
||||||
nnoremap <silent> <F5> <Cmd>lua require'dap'.continue()<CR>
|
|
||||||
nnoremap <silent> <F10> <Cmd>lua require'dap'.step_over()<CR>
|
|
||||||
nnoremap <silent> <F11> <Cmd>lua require'dap'.step_into()<CR>
|
|
||||||
nnoremap <silent> <F12> <Cmd>lua require'dap'.step_out()<CR>
|
|
||||||
nnoremap <silent> <Leader>b <Cmd>lua require'dap'.toggle_breakpoint()<CR>
|
|
||||||
nnoremap <silent> <Leader>B <Cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
|
|
||||||
nnoremap <silent> <Leader>lp <Cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
|
|
||||||
nnoremap <silent> <Leader>dr <Cmd>lua require'dap'.repl.open()<CR>
|
|
||||||
nnoremap <silent> <Leader>dl <Cmd>lua require'dap'.run_last()<CR>
|
|
||||||
|
|
||||||
|
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||||
|
350
rust.lua
Normal file
350
rust.lua
Normal file
@ -0,0 +1,350 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
|
local nvim_lsp = require 'lspconfig'
|
||||||
|
local c = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local deps = require("nvim-deps")
|
||||||
|
|
||||||
|
vim.g.rustaceanvim = {
|
||||||
|
tools = { -- rust-tools options
|
||||||
|
-- how to execute terminal commands
|
||||||
|
-- options right now: termopen / quickfix / toggleterm / vimux
|
||||||
|
executor = require("rust-tools.executors").termopen,
|
||||||
|
|
||||||
|
-- callback to execute once rust-analyzer is done initializing the workspace
|
||||||
|
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
|
||||||
|
on_initialized = nil,
|
||||||
|
|
||||||
|
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
|
||||||
|
reload_workspace_from_cargo_toml = true,
|
||||||
|
|
||||||
|
-- These apply to the default RustSetInlayHints command
|
||||||
|
inlay_hints = {
|
||||||
|
-- automatically set inlay hints (type hints)
|
||||||
|
-- default: true
|
||||||
|
auto = true,
|
||||||
|
|
||||||
|
-- Only show inlay hints for the current line
|
||||||
|
only_current_line = false,
|
||||||
|
|
||||||
|
-- whether 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 length 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,
|
||||||
|
|
||||||
|
-- The color of the hints
|
||||||
|
highlight = "Comment"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
|
||||||
|
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"}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Maximal width of the hover window. Nil means no max.
|
||||||
|
max_width = nil,
|
||||||
|
|
||||||
|
-- Maximal height of the hover window. Nil means no max.
|
||||||
|
max_height = nil,
|
||||||
|
|
||||||
|
-- whether the hover action window gets automatically focused
|
||||||
|
-- default: false
|
||||||
|
auto_focus = false
|
||||||
|
},
|
||||||
|
|
||||||
|
-- settings for showing the crate graph based on graphviz and the dot
|
||||||
|
-- command
|
||||||
|
crate_graph = {
|
||||||
|
-- Backend used for displaying the graph
|
||||||
|
-- see: https://graphviz.org/docs/outputs/
|
||||||
|
-- default: x11
|
||||||
|
backend = "x11",
|
||||||
|
-- where to store the output, nil for no output stored (relative
|
||||||
|
-- path from pwd)
|
||||||
|
-- default: nil
|
||||||
|
output = nil,
|
||||||
|
-- true for all crates.io and external crates, false only the local
|
||||||
|
-- crates
|
||||||
|
-- default: true
|
||||||
|
full = true,
|
||||||
|
|
||||||
|
-- List of backends found on: https://graphviz.org/docs/outputs/
|
||||||
|
-- Is used for input validation and autocompletion
|
||||||
|
-- Last updated: 2021-08-26
|
||||||
|
enabled_graphviz_backends = {
|
||||||
|
"bmp", "cgimage", "canon", "dot", "gv", "xdot", "xdot1.2",
|
||||||
|
"xdot1.4", "eps", "exr", "fig", "gd", "gd2", "gif", "gtk",
|
||||||
|
"ico", "cmap", "ismap", "imap", "cmapx", "imap_np", "cmapx_np",
|
||||||
|
"jpg", "jpeg", "jpe", "jp2", "json", "json0", "dot_json",
|
||||||
|
"xdot_json", "pdf", "pic", "pct", "pict", "plain", "plain-ext",
|
||||||
|
"png", "pov", "ps", "ps2", "psd", "sgi", "svg", "svgz", "tga",
|
||||||
|
"tiff", "tif", "tk", "vml", "vmlz", "wbmp", "webp", "xlib",
|
||||||
|
"x11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 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/doc/server_configurations.md#rust_analyzer
|
||||||
|
server = {
|
||||||
|
-- standalone file support
|
||||||
|
-- setting it to false may improve startup time
|
||||||
|
standalone = true,
|
||||||
|
cmd = {(deps.rust_analyzer_path .. "/bin/rust-analyzer")},
|
||||||
|
capabilities = require("cmp_nvim_lsp").default_capabilities(c),
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
require("lsp-inlayhints").on_attach(client, bufnr)
|
||||||
|
require('crates').setup()
|
||||||
|
local keymap_opts = {buffer = bufnr}
|
||||||
|
-- Hover actions
|
||||||
|
-- call twice to focus
|
||||||
|
vim.keymap.set("n", "<leader>K",
|
||||||
|
function()
|
||||||
|
vim.cmd.RustLsp {'hover', 'actions'}
|
||||||
|
end, keymap_opts)
|
||||||
|
-- Code action groups
|
||||||
|
vim.keymap.set("n", "<leader>as",
|
||||||
|
function()
|
||||||
|
vim.cmd.RustLsp {'hover', 'actions'}
|
||||||
|
end, keymap_opts)
|
||||||
|
vim.keymap.set('n', '<leader>cc',
|
||||||
|
function() vim.cmd.RustLsp('openCargo') end,
|
||||||
|
keymap_opts)
|
||||||
|
vim.keymap.set('n', '<leader>cr', function()
|
||||||
|
vim.cmd.RustLsp {'runnables', 'last' --[[ optional ]] }
|
||||||
|
end, keymap_opts)
|
||||||
|
vim.keymap.set('n', '<leader>cd', function()
|
||||||
|
vim.cmd.RustLsp {'debuggables', 'last' --[[ optional ]] }
|
||||||
|
end, keymap_opts)
|
||||||
|
-- vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts)
|
||||||
|
local diag_float_grp = vim.api.nvim_create_augroup(
|
||||||
|
"DiagnosticFloat", {clear = true})
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
callback = function()
|
||||||
|
vim.diagnostic.open_float(nil, {focusable = false})
|
||||||
|
end,
|
||||||
|
group = diag_float_grp
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Goto previous/next diagnostic warning/error
|
||||||
|
vim.keymap.set("n", "g[", vim.diagnostic.goto_prev, keymap_opts)
|
||||||
|
vim.keymap.set("n", "g]", vim.diagnostic.goto_next, keymap_opts)
|
||||||
|
end
|
||||||
|
}, -- rust-analyzer options
|
||||||
|
|
||||||
|
-- debugging stuff
|
||||||
|
dap = {
|
||||||
|
adapter = {
|
||||||
|
type = "executable",
|
||||||
|
command = deps.lldb_path .. "/bin/lldb-vscode",
|
||||||
|
name = "rt_lldb"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
=======
|
||||||
|
local rt = require("rust-tools")
|
||||||
|
local deps = require("nvim-deps")
|
||||||
|
|
||||||
|
rt.setup(
|
||||||
|
{
|
||||||
|
tools = { -- rust-tools options
|
||||||
|
|
||||||
|
-- how to execute terminal commands
|
||||||
|
-- options right now: termopen / quickfix / toggleterm / vimux
|
||||||
|
executor = require("rust-tools.executors").termopen,
|
||||||
|
|
||||||
|
-- callback to execute once rust-analyzer is done initializing the workspace
|
||||||
|
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
|
||||||
|
on_initialized = nil,
|
||||||
|
|
||||||
|
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
|
||||||
|
reload_workspace_from_cargo_toml = true,
|
||||||
|
|
||||||
|
-- These apply to the default RustSetInlayHints command
|
||||||
|
inlay_hints = {
|
||||||
|
-- automatically set inlay hints (type hints)
|
||||||
|
-- default: true
|
||||||
|
auto = true,
|
||||||
|
|
||||||
|
-- Only show inlay hints for the current line
|
||||||
|
only_current_line = false,
|
||||||
|
|
||||||
|
-- whether 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 length 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,
|
||||||
|
|
||||||
|
-- The color of the hints
|
||||||
|
highlight = "Comment",
|
||||||
|
},
|
||||||
|
|
||||||
|
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
|
||||||
|
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" },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Maximal width of the hover window. Nil means no max.
|
||||||
|
max_width = nil,
|
||||||
|
|
||||||
|
-- Maximal height of the hover window. Nil means no max.
|
||||||
|
max_height = nil,
|
||||||
|
|
||||||
|
-- whether the hover action window gets automatically focused
|
||||||
|
-- default: false
|
||||||
|
auto_focus = false,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- settings for showing the crate graph based on graphviz and the dot
|
||||||
|
-- command
|
||||||
|
crate_graph = {
|
||||||
|
-- Backend used for displaying the graph
|
||||||
|
-- see: https://graphviz.org/docs/outputs/
|
||||||
|
-- default: x11
|
||||||
|
backend = "x11",
|
||||||
|
-- where to store the output, nil for no output stored (relative
|
||||||
|
-- path from pwd)
|
||||||
|
-- default: nil
|
||||||
|
output = nil,
|
||||||
|
-- true for all crates.io and external crates, false only the local
|
||||||
|
-- crates
|
||||||
|
-- default: true
|
||||||
|
full = true,
|
||||||
|
|
||||||
|
-- List of backends found on: https://graphviz.org/docs/outputs/
|
||||||
|
-- Is used for input validation and autocompletion
|
||||||
|
-- Last updated: 2021-08-26
|
||||||
|
enabled_graphviz_backends = {
|
||||||
|
"bmp",
|
||||||
|
"cgimage",
|
||||||
|
"canon",
|
||||||
|
"dot",
|
||||||
|
"gv",
|
||||||
|
"xdot",
|
||||||
|
"xdot1.2",
|
||||||
|
"xdot1.4",
|
||||||
|
"eps",
|
||||||
|
"exr",
|
||||||
|
"fig",
|
||||||
|
"gd",
|
||||||
|
"gd2",
|
||||||
|
"gif",
|
||||||
|
"gtk",
|
||||||
|
"ico",
|
||||||
|
"cmap",
|
||||||
|
"ismap",
|
||||||
|
"imap",
|
||||||
|
"cmapx",
|
||||||
|
"imap_np",
|
||||||
|
"cmapx_np",
|
||||||
|
"jpg",
|
||||||
|
"jpeg",
|
||||||
|
"jpe",
|
||||||
|
"jp2",
|
||||||
|
"json",
|
||||||
|
"json0",
|
||||||
|
"dot_json",
|
||||||
|
"xdot_json",
|
||||||
|
"pdf",
|
||||||
|
"pic",
|
||||||
|
"pct",
|
||||||
|
"pict",
|
||||||
|
"plain",
|
||||||
|
"plain-ext",
|
||||||
|
"png",
|
||||||
|
"pov",
|
||||||
|
"ps",
|
||||||
|
"ps2",
|
||||||
|
"psd",
|
||||||
|
"sgi",
|
||||||
|
"svg",
|
||||||
|
"svgz",
|
||||||
|
"tga",
|
||||||
|
"tiff",
|
||||||
|
"tif",
|
||||||
|
"tk",
|
||||||
|
"vml",
|
||||||
|
"vmlz",
|
||||||
|
"wbmp",
|
||||||
|
"webp",
|
||||||
|
"xlib",
|
||||||
|
"x11",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 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/doc/server_configurations.md#rust_analyzer
|
||||||
|
server = {
|
||||||
|
-- standalone file support
|
||||||
|
-- setting it to false may improve startup time
|
||||||
|
standalone = true,
|
||||||
|
cmd = { (deps.rust_analyzer_path .. "/bin/rust-analyzer") },
|
||||||
|
}, -- rust-analyzer options
|
||||||
|
|
||||||
|
-- debugging stuff
|
||||||
|
dap = {
|
||||||
|
adapter = {
|
||||||
|
type = "executable",
|
||||||
|
command = deps.lldb_path .. "lldb-vscode",
|
||||||
|
name = "rt_lldb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
>>>>>>> 5df3a02 (wip: feat(nvim/rust-tools): begin migration)
|
Loading…
x
Reference in New Issue
Block a user