From 5c547d92cc9ec084478059d40368c1c3f227820b Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Fri, 20 Oct 2023 15:01:42 -0400 Subject: [PATCH] updates --- lua/keymaps.lua | 201 +++++++------ lua/plugins/lsp.lua | 575 +++++++++++++++++++------------------- lua/plugins/telescope.lua | 203 +++++++------- 3 files changed, 502 insertions(+), 477 deletions(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index d237ff6..6a14770 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -12,96 +12,113 @@ vim.g.maplocalleader = " " -- command_mode = "c", require("util").keymaps({ - n = { - [";"] = { ":", desc = "No shift command mode" }, - ["n"] = { "nzzzv", desc = "Next search result centered" }, - ["N"] = { "Nzzzv", desc = "Previous search result centered" }, - [""] = { ":noh", desc = "Clear search on escape" }, - [""] = { ":noh", desc = "Clear search on return" }, - ["a"] = { "ggVG", desc = "Select all" }, - ["w"] = { "w", desc = "Save" }, - ["qq"] = { "confirm q", desc = "Quit" }, - ["bq"] = { "bp|bd #", desc = "Close current buffer only" }, - ["tn"] = { "tabnew", desc = "Create new tab" }, - ["tq"] = { "tabclose", desc = "Close current tab" }, - ["|"] = { "vsplit", desc = "Vertical Split" }, - ["\\"] = { "split", desc = "Horizontal Split" }, - [""] = { "zz", desc = "Vertical half page down and center cursor" }, - [""] = { "zz", desc = "Vertical half page up and center cursor" }, - ["y"] = { '"*y', desc = "Copy to system clipboard" }, - ["p"] = { '"*p', desc = "Paste from system clipboard" }, - ["Q"] = { "Neotree closeqa", desc = "Quit all" }, - ["q"] = { "Neotree closeqa", desc = "Quit all" }, - ["J"] = { "mzJ`z", desc = "Move line below onto this line" }, - [""] = { "", desc = "Go back " }, - -- window navigation - [""] = { "h", desc = "Move window left current" }, - [""] = { "j", desc = "Move window below current" }, - [""] = { "k", desc = "Move window above current" }, - [""] = { "l", desc = "Move window right current" }, - -- tab navigation - ["H"] = { "tabprevious", desc = "Move to previous tab" }, - ["L"] = { "tabnext", desc = "Move to next tab" }, - -- reformat LSP - ["l"] = { - function() - -- vim.cmd "SqlxFormat" - vim.lsp.buf.format() - end, - desc = "Reformat file", - }, - ["ls"] = { "SqlxFormat", desc = "Format sqlx queries in rust raw string literals." }, - ["ld"] = { - function() - vim.diagnostic.open_float() - end, - desc = "Show diagnostic message", - }, - ["ll"] = { - function() - vim.diagnostic.setloclist() - end, - desc = "Show diagnostic list", - }, - ["lz"] = { "e", desc = "Edit current file again / Restart LSP Server" }, - [",uu"] = { ':let @u = trim(tolower(system("uuidgen")))au', desc = "Generate and insert UUID" }, - ["B"] = { "b#", desc = "Switch to last buffer" }, - ["S"] = { - "set equalalwaysset noequalalways", - desc = "Equalize/resize screens evenly", - }, - }, - v = { - ["J"] = { ":m '>+1gv=gv", desc = "Visually move block down" }, - ["K"] = { ":m '<-2gv=gv", desc = "Visually move block up" }, - [",uu"] = { - 'd:let @u = trim(tolower(system("uuidgen")))iu', - desc = "Generate and replace UUID", - }, - ["y"] = { '"*y', desc = "Copy to system clipboard" }, - ["p"] = { '"*p', desc = "Paste from system clipboard" }, - ["p"] = { '"_dP', desc = "Paste without yanking replaced content" }, - [""] = { '"hy:%s/h//g', desc = "Replace current selection" }, - [">"] = { "> gv", desc = "Indent selection" }, - ["<"] = { "< gv", desc = "Outdent selection" }, - }, - i = { - [""] = { "", desc = "Up" }, - [""] = { "", desc = "Down" }, - [""] = { "", desc = "Left" }, - [""] = { "", desc = "Right" }, - [""] = { "", desc = "End" }, - [""] = { "", desc = "Home" }, - }, - c = { - [""] = { "", desc = "Left" }, - [""] = { "", desc = "Down" }, - [""] = { "", desc = "Up" }, - [""] = { "", desc = "Right" }, - [""] = { "", desc = "End" }, - [""] = { "", desc = "Home" }, - }, - t = { - [""] = { "", desc = "Escape the terminal" }, - }, + n = { + [";"] = { ":", desc = "No shift command mode" }, + ["n"] = { "nzzzv", desc = "Next search result centered" }, + ["N"] = { "Nzzzv", desc = "Previous search result centered" }, + [""] = { ":noh", desc = "Clear search on escape" }, + [""] = { ":noh", desc = "Clear search on return" }, + ["a"] = { "ggVG", desc = "Select all" }, + ["w"] = { "w", desc = "Save" }, + ["qq"] = { + function() + -- Use to have this which always closed and quit ont he last screen: "confirm q" + -- Instead I want this behavior: + -- if only 1 screen is open then close all buffers, resulting in a blank unamed buffer window similar to fresh session + -- else if more than 1 screen, confirm q to close that screen + -- Check the number of screens + if vim.fn.winnr("$") == 1 then + -- If only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session + vim.cmd("bufdo bd") + vim.cmd("SessionDelete") + else + -- If more than 1 screen, confirm q to close that screen + vim.cmd("confirm q") + end + end, + desc = "Quit ", + }, + ["bq"] = { "bp|bd #", desc = "Close current buffer only" }, + ["tn"] = { "tabnew", desc = "Create new tab" }, + ["tq"] = { "tabclose", desc = "Close current tab" }, + ["|"] = { "vsplit", desc = "Vertical Split" }, + ["\\"] = { "split", desc = "Horizontal Split" }, + [""] = { "zz", desc = "Vertical half page down and center cursor" }, + [""] = { "zz", desc = "Vertical half page up and center cursor" }, + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + -- ["Q"] = { "Neotree closeqa", desc = "Quit all" }, + ["q"] = { "Neotree closeqa", desc = "Quit all" }, + ["J"] = { "mzJ`z", desc = "Move line below onto this line" }, + [""] = { "", desc = "Go back " }, + -- window navigation + [""] = { "h", desc = "Move window left current" }, + [""] = { "j", desc = "Move window below current" }, + [""] = { "k", desc = "Move window above current" }, + [""] = { "l", desc = "Move window right current" }, + -- tab navigation + ["H"] = { "tabprevious", desc = "Move to previous tab" }, + ["L"] = { "tabnext", desc = "Move to next tab" }, + -- reformat LSP + ["l"] = { + function() + -- vim.cmd "SqlxFormat" + vim.lsp.buf.format() + end, + desc = "Reformat file", + }, + ["ls"] = { "SqlxFormat", desc = "Format sqlx queries in rust raw string literals." }, + ["ld"] = { + function() + vim.diagnostic.open_float() + end, + desc = "Show diagnostic message", + }, + ["ll"] = { + function() + vim.diagnostic.setloclist() + end, + desc = "Show diagnostic list", + }, + ["lz"] = { "e", desc = "Edit current file again / Restart LSP Server" }, + [",uu"] = { ':let @u = trim(tolower(system("uuidgen")))au', desc = "Generate and insert UUID" }, + ["B"] = { "b#", desc = "Switch to last buffer" }, + ["S"] = { + "set equalalwaysset noequalalways", + desc = "Equalize/resize screens evenly", + }, + }, + v = { + ["J"] = { ":m '>+1gv=gv", desc = "Visually move block down" }, + ["K"] = { ":m '<-2gv=gv", desc = "Visually move block up" }, + [",uu"] = { + 'd:let @u = trim(tolower(system("uuidgen")))iu', + desc = "Generate and replace UUID", + }, + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + ["p"] = { '"_dP', desc = "Paste without yanking replaced content" }, + [""] = { '"hy:%s/h//g', desc = "Replace current selection" }, + [">"] = { "> gv", desc = "Indent selection" }, + ["<"] = { "< gv", desc = "Outdent selection" }, + }, + i = { + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Right" }, + [""] = { "", desc = "End" }, + [""] = { "", desc = "Home" }, + }, + c = { + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Right" }, + [""] = { "", desc = "End" }, + [""] = { "", desc = "Home" }, + }, + t = { + [""] = { "", desc = "Escape the terminal" }, + }, }) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 0157006..7618572 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,88 +1,88 @@ local function prereqs() - local output = vim.fn.system({ - "which", - "rust-analyzer", - "&&", - "rust-analyzer", - "--version", - }) - if output == nil or output == "" or string.find(output, "not installed for the toolchain") then - print("Installing rust-analyzer globally with rustup") - vim.fn.system({ - "rustup", - "component", - "add", - "rust-analyzer", - }) - end + local output = vim.fn.system({ + "which", + "rust-analyzer", + "&&", + "rust-analyzer", + "--version", + }) + if output == nil or output == "" or string.find(output, "not installed for the toolchain") then + print("Installing rust-analyzer globally with rustup") + vim.fn.system({ + "rustup", + "component", + "add", + "rust-analyzer", + }) + end end local servers = { - -- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE - tsserver = { - -- typescript/javascript - }, - pyright = { - -- python - }, - lua_ls = { - -- lua - Lua = { - runtime = { - version = "LuaJIT", - }, - workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) }, - telemetry = { enable = false }, - diagnostics = { - globals = { - "vim", - "require", - }, - }, - }, - }, - bashls = { - -- bash - }, - cssls = { - -- css - }, - cssmodules_ls = { - -- css modules - }, - dockerls = { - -- docker - }, - docker_compose_language_service = { - -- docker compose - }, - jsonls = { - -- json - }, - marksman = { - -- markdown - }, - taplo = { - -- toml - }, - yamlls = { - -- yaml - }, - lemminx = { - -- xml - }, - rnix = { - -- Nix - }, - ansiblels = { - -- ansible - }, + -- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE + tsserver = { + -- typescript/javascript + }, + pyright = { + -- python + }, + lua_ls = { + -- lua + Lua = { + runtime = { + version = "LuaJIT", + }, + workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) }, + telemetry = { enable = false }, + diagnostics = { + globals = { + "vim", + "require", + }, + }, + }, + }, + bashls = { + -- bash + }, + cssls = { + -- css + }, + cssmodules_ls = { + -- css modules + }, + dockerls = { + -- docker + }, + docker_compose_language_service = { + -- docker compose + }, + jsonls = { + -- json + }, + marksman = { + -- markdown + }, + taplo = { + -- toml + }, + yamlls = { + -- yaml + }, + lemminx = { + -- xml + }, + rnix = { + -- Nix + }, + ansiblels = { + -- ansible + }, } vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = true, - signs = true, - update_in_insert = true, + virtual_text = true, + signs = true, + update_in_insert = true, }) -- LSP config @@ -90,234 +90,239 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagn -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(client, 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 - nmap("lr", vim.lsp.buf.rename, "[R]ename") - nmap("la", vim.lsp.buf.code_action, "Code [A]ction") + local cursor_layout = { + layout_strategy = "cursor", + layout_config = { width = 0.25, height = 0.35 }, + } - 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("D", vim.lsp.buf.type_definition, "Type [D]efinition") + nmap("lr", vim.lsp.buf.rename, "[R]ename") + nmap("la", vim.lsp.buf.code_action, "Code [A]ction") - -- See `:help K` for why this keymap - nmap("K", vim.lsp.buf.hover, "Hover Documentation") - nmap("sd", vim.lsp.buf.signature_help, "Signature Documentation") + -- I dont like the default vim quickfix buffer opening for goto defintiion so use telescope + -- nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + nmap("gd", function() + require("telescope.builtin").lsp_definitions(cursor_layout) + end, "[G]oto [D]efinition") + nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + nmap("gI", function() + require("telescope.builtin").lsp_implementations(cursor_layout) + end, "[G]oto [I]mplementation") - -- Lesser used LSP functionality - nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + -- See `:help K` for why this keymap + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + nmap("sd", vim.lsp.buf.signature_help, "Signature Documentation") - -- disable tsserver so it does not conflict with prettier - if client.name == "tsserver" then - client.server_capabilities.document_formatting = false - end + -- Lesser used LSP functionality + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + + -- disable tsserver so it does not conflict with prettier + if client.name == "tsserver" then + client.server_capabilities.document_formatting = false + end end local gen_capabilities = function(cmp) - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = cmp.default_capabilities(capabilities) + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = cmp.default_capabilities(capabilities) end return { - { - "lvimuser/lsp-inlayhints.nvim", - }, - { - "L3MON4D3/LuaSnip", - build = "make install_jsregexp", - opts = { - history = true, - region_check_events = "InsertEnter", - delete_check_events = "TextChanged,InsertLeave", - } - }, - { - -- Autocompletion - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "L3MON4D3/LuaSnip", - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - --"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua - "zbirenbaum/copilot-cmp", - }, - }, - { - "williamboman/mason.nvim", - cmd = { - "Mason", - "MasonUpdate", - "MasonInstall", - "MasonInstallAll", - "MasonUninstall", - "MasonUninstallAll", - "MasonLog", - }, - build = ":MasonUpdate", - opts = {}, - }, - { "folke/neodev.nvim", opts = {} }, -- lua stuff - { - "williamboman/mason-lspconfig.nvim", - }, - { - "neovim/nvim-lspconfig", - dependencies = { "nvim-telescope/telescope.nvim" }, - config = function() - local config = require("lspconfig") - -- local util = require("lspconfig/util") - local mason_lspconfig = require("mason-lspconfig") - local cmp = require("cmp") - local luasnip = require("luasnip") + { + "lvimuser/lsp-inlayhints.nvim", + }, + { + "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + opts = { + history = true, + region_check_events = "InsertEnter", + delete_check_events = "TextChanged,InsertLeave", + }, + }, + { + -- Autocompletion + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + --"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua + "zbirenbaum/copilot-cmp", + }, + }, + { + "williamboman/mason.nvim", + cmd = { + "Mason", + "MasonUpdate", + "MasonInstall", + "MasonInstallAll", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + }, + build = ":MasonUpdate", + opts = {}, + }, + { "folke/neodev.nvim", opts = {} }, -- lua stuff + { + "williamboman/mason-lspconfig.nvim", + }, + { + "neovim/nvim-lspconfig", + dependencies = { "nvim-telescope/telescope.nvim" }, + config = function() + local config = require("lspconfig") + -- local util = require("lspconfig/util") + local mason_lspconfig = require("mason-lspconfig") + local cmp = require("cmp") + local luasnip = require("luasnip") - -- LSP - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers - local capabilities = gen_capabilities(require("cmp_nvim_lsp")) + -- LSP + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = gen_capabilities(require("cmp_nvim_lsp")) - -- Install servers used - mason_lspconfig.setup({ - ensure_installed = vim.tbl_keys(servers), - }) + -- Install servers used + mason_lspconfig.setup({ + ensure_installed = vim.tbl_keys(servers), + }) - local flags = { - allow_incremental_sync = true, - debounce_text_changes = 200, - } + local flags = { + allow_incremental_sync = true, + debounce_text_changes = 200, + } - mason_lspconfig.setup_handlers({ - function(server_name) - config[server_name].setup({ - flags = flags, - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - }) - end, - }) + mason_lspconfig.setup_handlers({ + function(server_name) + config[server_name].setup({ + flags = flags, + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + }) + end, + }) - -- Completion - luasnip.config.setup({}) + -- Completion + luasnip.config.setup({}) - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- elseif luasnip.expand_or_jumpable() then - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = { - { - name = "copilot", - priority = 8, - keyword_length = 1, - filter = function(keyword) - -- Check if keyword length is some number and not just whitespace - if #keyword < 2 or keyword:match("^%s*$") then - return false - end - return true - end, - }, - { name = "nvim_lsp", priority = 9 }, - { nane = "buffer", priority = 7 }, - { name = "luasnip", priority = 6 }, - { name = "path" }, - { name = "crates" }, - }, - sorting = { - priority_weight = 1, - comparators = { - cmp.config.compare.locality, - cmp.config.compare.recently_used, - cmp.config.compare.score, - cmp.config.compare.offset, - cmp.config.compare.order, - }, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - }) + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- elseif luasnip.expand_or_jumpable() then + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = { + { + name = "copilot", + priority = 8, + keyword_length = 1, + filter = function(keyword) + -- Check if keyword length is some number and not just whitespace + if #keyword < 2 or keyword:match("^%s*$") then + return false + end + return true + end, + }, + { name = "nvim_lsp", priority = 9 }, + { nane = "buffer", priority = 7 }, + { name = "luasnip", priority = 6 }, + { name = "path" }, + { name = "crates" }, + }, + sorting = { + priority_weight = 1, + comparators = { + cmp.config.compare.locality, + cmp.config.compare.recently_used, + cmp.config.compare.score, + cmp.config.compare.offset, + cmp.config.compare.order, + }, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + }) + -- Window borders for visibility + local _border = "single" - -- Window borders for visibility - local _border = "single" + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = _border, + }) - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { - border = _border - } - ) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = _border, + }) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( - vim.lsp.handlers.signature_help, { - border = _border - } - ) + vim.diagnostic.config({ + float = { border = _border }, + }) - vim.diagnostic.config { - float = { border = _border } - } - - require('lspconfig.ui.windows').default_options = { - border = _border - } - end, - }, - { -- Rust tools - "simrat39/rust-tools.nvim", - build = prereqs, - opts = { - server = { - on_attach = on_attach, - }, - }, - config = function(_, opts) - opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp")) - require("rust-tools").setup(opts) - end, - --config = function(_, opts) - --require('rust-tools').setup(opts) - --end - }, - { "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} }, + require("lspconfig.ui.windows").default_options = { + border = _border, + } + end, + }, + { -- Rust tools + "simrat39/rust-tools.nvim", + build = prereqs, + opts = { + server = { + on_attach = on_attach, + }, + }, + config = function(_, opts) + opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp")) + require("rust-tools").setup(opts) + end, + --config = function(_, opts) + --require('rust-tools').setup(opts) + --end + }, + { "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} }, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 7b06058..131c7c5 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,105 +1,108 @@ local function prereqs() - local output = vim.fn.system({ - "which", - "rg", - }) - if output == nil or output == "" or string.find(output, "not installed for the toolchain") then - print("Installing ripgrep globally with rtx") - vim.fn.system({ - "rtx", - "global", - "ripgrep@latest", - }) - end + local output = vim.fn.system({ + "which", + "rg", + }) + if output == nil or output == "" or string.find(output, "not installed for the toolchain") then + print("Installing ripgrep globally with rtx") + vim.fn.system({ + "rtx", + "global", + "ripgrep@latest", + }) + end end return { - "nvim-telescope/telescope.nvim", - tag = "0.1.1", - dependencies = { - { "nvim-lua/plenary.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable("make") == 1, build = "make" }, - }, - build = prereqs, - cmd = "Telescope", - keys = { - { "f", "", desc = "Find ..." }, - { - "fr", - function() - require("telescope.builtin").resume() - end, - desc = "Resume last telescope", - }, - { - "ff", - function() - require("telescope.builtin").find_files({ - hidden = true, - }) - end, - desc = "Find Files", - }, - { - "fg", - function() - require("telescope.builtin").git_files() - end, - desc = "Find Git only Files", - }, - { - "fw", - function() - if vim.fn.executable("rg") == 0 then - vim.notify("rg not installed, live grep will not function.", 3) - end - require("telescope.builtin").live_grep({ - grep_open_files = true, - }) - end, - desc = "Find Words", - }, - { - "fc", - function() - require("telescope.builtin").commands() - end, - desc = "Find Commands", - }, - { - "fk", - function() - require("telescope.builtin").keymaps() - end, - desc = "Find Commands", - }, - { - "fb", - function() - require("telescope.builtin").buffers() - end, - desc = "Find Commands", - }, - { - "lfr", - function() - require("telescope.builtin").lsp_references() - end, - desc = "Find References", mode ={"n", "v", "x"} - }, - }, - opts = { - pickers = { - buffers = { - sort_lastused = true, - }, - find_files = { - hidden = true, - sort_lastused = true, - }, - }, - defaults = { - file_ignore_patterns = { "node_modules", "package-lock.json", "target" }, - }, - }, + "nvim-telescope/telescope.nvim", + tag = "0.1.1", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable("make") == 1, build = "make" }, + }, + build = prereqs, + cmd = "Telescope", + keys = { + { "f", "", desc = "Find ..." }, + { + "fr", + function() + require("telescope.builtin").resume() + end, + desc = "Resume last telescope", + }, + { + "ff", + function() + require("telescope.builtin").find_files({ + hidden = true, + }) + end, + desc = "Find Files", + }, + { + "fg", + function() + require("telescope.builtin").git_files({ + hidden = true, + }) + end, + desc = "Find Git only Files", + }, + { + "fw", + function() + if vim.fn.executable("rg") == 0 then + vim.notify("rg not installed, live grep will not function.", 3) + end + require("telescope.builtin").live_grep({ + hidden = true, + }) + end, + desc = "Find Words", + }, + { + "fc", + function() + require("telescope.builtin").commands() + end, + desc = "Find Commands", + }, + { + "fk", + function() + require("telescope.builtin").keymaps() + end, + desc = "Find Commands", + }, + { + "fb", + function() + require("telescope.builtin").buffers() + end, + desc = "Find Commands", + }, + { + "lfr", + function() + require("telescope.builtin").lsp_references() + end, + desc = "Find References", + mode = { "n", "v", "x" }, + }, + }, + opts = { + pickers = { + buffers = { + sort_lastused = true, + }, + find_files = { + hidden = true, + sort_lastused = true, + }, + }, + defaults = { + file_ignore_patterns = { "node_modules", "package-lock.json", "target" }, + }, + }, }