Skip to content
Snippets Groups Projects
Commit b33e41c1 authored by codecraft's avatar codecraft :crocodile:
Browse files

Formatting some files, adding `rd` keybind for RustDebugables

parent 228d55b4
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,7 @@ local servers = {
buildScripts = {
enable = true,
},
all_features = true,
},
procMacro = {
enable = true,
......
local null_ls = require('null-ls')
local mason_null_ls = require('mason-null-ls')
local null_ls = require("null-ls")
local mason_null_ls = require("mason-null-ls")
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
......@@ -7,38 +7,38 @@ local diagnostics = null_ls.builtins.diagnostics
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local formatters_linters = {
prettier = {},
rustfmt = {},
black = {},
stylua = {},
prettier = {},
rustfmt = {},
black = {},
stylua = {},
}
mason_null_ls.setup({
ensure_installed = vim.tbl_keys(formatters_linters)
ensure_installed = vim.tbl_keys(formatters_linters),
})
null_ls.setup ({
sources = {
formatting.prettier,
formatting.rustfmt,
formatting.black,
formatting.stylua,
},
on_attach = function(current_client, bufnr)
if current_client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
filter = function(client)
-- only use null-ls for formatting instead of lsp server
return client.name == "null-ls"
end,
bufnr = bufnr,
})
end,
})
end
end,
null_ls.setup({
sources = {
formatting.prettier,
formatting.rustfmt,
formatting.black,
formatting.stylua,
},
on_attach = function(current_client, bufnr)
if current_client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
filter = function(client)
-- only use null-ls for formatting instead of lsp server
return client.name == "null-ls"
end,
bufnr = bufnr,
})
end,
})
end
end,
})
......@@ -7,62 +7,62 @@ local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.so"
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<leader>h", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<leader>h", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
vim.keymap.set("n", "<leader>rd", "<CMD>RustDebuggables<CR>", { buffer = bufnr })
local nmap = function(keys, func, desc)
if desc then
desc = "LSP: " .. desc
end
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
if _.server_capabilities.documentSymbolProvider then
require("nvim-navic").attach(_, bufnr)
end
if _.server_capabilities.documentSymbolProvider then
require('nvim-navic').attach(_, bufnr)
end
nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
nmap("<leader>di", vim.diagnostic.open_float, "[D]iagnostic [I]nfo")
nmap("<leader>dv", "<cmd>Telescope diagnostics<CR>", "[D]iagnostic [V]iew")
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('<leader>di', vim.diagnostic.open_float, '[D]iagnostic [I]nfo')
nmap('<leader>dv', '<cmd>Telescope diagnostics<CR>', '[D]iagnostic [V]iew')
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap("<leader>K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<leader>k", vim.lsp.buf.signature_help, "Signature Documentation")
-- See `:help K` for why this keymap
nmap('<leader>K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<leader>k', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end,
},
tools = {
hover_actions = {
auto_focus = true,
}
},
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
},
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
end, { desc = "Format current buffer with LSP" })
end,
},
tools = {
hover_actions = {
auto_focus = true,
},
},
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
},
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment