From 9a426b476ce2983165329aa907bfb0a5e1ff3f98 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Tue, 8 Oct 2024 09:56:24 +0100 Subject: [PATCH] better telescope config --- after/ftplugin/rust.lua | 4 +- lazy-lock.json | 29 ++++----- lua/configs/lspconfig.lua | 3 + lua/configs/telescope.lua | 22 +++++++ lua/plugins/telescope.lua | 29 +++++++-- lua/plugins/theme.lua | 27 ++++++++ lua/plugins/treesitter.lua | 122 +++++++++++++++++++++++++------------ 7 files changed, 176 insertions(+), 60 deletions(-) create mode 100644 lua/plugins/theme.lua diff --git a/after/ftplugin/rust.lua b/after/ftplugin/rust.lua index 4afb6a5..2392a44 100644 --- a/after/ftplugin/rust.lua +++ b/after/ftplugin/rust.lua @@ -2,7 +2,7 @@ local bufnr = vim.api.nvim_get_current_buf() local opts = { buffer = bufnr } vim.keymap.set("n", "ga", function() - vim.cmd.RustLsp("codeAction") + vim.cmd.RustLsp "codeAction" end, opts) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) @@ -13,5 +13,5 @@ vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) vim.keymap.set("n", "t", function() - vim.cmd.RustLsp({ "testables" }) + vim.cmd.RustLsp { "testables" } end, opts) diff --git a/lazy-lock.json b/lazy-lock.json index ab6c871..30563e1 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,8 @@ { "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, - "NvChad": { "branch": "v2.5", "commit": "b83a949d9e883b6ab98070f224535f1018174a5d" }, - "base46": { "branch": "v2.5", "commit": "85e10a6ecbb8a9a0ca2db0a2c22f656c739925a3" }, + "NvChad": { "branch": "v2.5", "commit": "a69f893e49ee36d4c74431044b40f08042c396a2" }, + "base46": { "branch": "v2.5", "commit": "177af7c0e492f6332bf78675a47b8983b1a32291" }, + "catppuccin": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, @@ -9,38 +10,38 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "40d4e98fcc3e6f485f0e8924c63734bc7e305967" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" }, - "fzf-lua": { "branch": "main", "commit": "ace9968be267b034e450be4feaf6e9107bc34fbd" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "fzf-lua": { "branch": "main", "commit": "1e03541de4d8a169defe83bb4d7abfba450c63a1" }, "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, "hardtime.nvim": { "branch": "main", "commit": "6513bf42cd9261669d1ee41ff8b4065dfdc53a09" }, "hop.nvim": { "branch": "master", "commit": "8f51ef02700bb3cdcce94e92eff16170a6343c4f" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3af6493bf69e4a857a8b1fab36f333629d413a18" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, "lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" }, "local-highlight.nvim": { "branch": "master", "commit": "ae3ada3a332128b1036c84c8587b9069891c63da" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "menu": { "branch": "main", "commit": "e8a2ae036b71e4808a7c73cf12dbeaa3f7e4dd5c" }, + "menu": { "branch": "main", "commit": "ea606f6ab2430db0aece8075e62c14132b815ae1" }, "mini.pick": { "branch": "main", "commit": "6d66ae9eb0b75261f1842788dda611285b6f065f" }, "minty": { "branch": "main", "commit": "8809b2c7c2edbeb3fa9c3b05bd2e89934d54f526" }, - "neogit": { "branch": "master", "commit": "d55bf6114c6cfba013e4c0e817e29e7752554ab7" }, + "neogit": { "branch": "master", "commit": "c3ff049446e0920d02a5828c4e3619243d3c6e15" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-lspconfig": { "branch": "master", "commit": "39f31e178466e4ed23c8ea6fddd5b7a4d9699398" }, + "nvim-lspconfig": { "branch": "master", "commit": "04680101ff79e99b4e33a4386ec27cbd0d360c75" }, "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, - "nvim-tree.lua": { "branch": "master", "commit": "c9104a5d079db5a158c9562c54689df27d52dccc" }, - "nvim-treesitter": { "branch": "master", "commit": "45386764cc9535200d2288cab929c5093d33660e" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "4a2d05ec24eaa6b655c7d19092a3b6c0219d46b9" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "44fd461b879d80a21d5041f312f070f22551c0bc" }, + "nvim-tree.lua": { "branch": "master", "commit": "50e919426a4a2053f78b2f8ab001c8ad8eb47ef6" }, + "nvim-treesitter": { "branch": "master", "commit": "86c10df7ef77daf45a0e4a918934bb59083db1e1" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "b91c98afa6c42819aea6cbc1ba38272f5456a5cf" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" }, "nvim-web-devicons": { "branch": "master", "commit": "56f17def81478e406e3a8ec4aa727558e79786f3" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "rustaceanvim": { "branch": "master", "commit": "29f42cc149f915d771c550b6dfe7c788d856cf04" }, "statuscol.nvim": { "branch": "main", "commit": "ecc04176e364dd7f614edfc4325e3a8521905ad6" }, - "telescope.nvim": { "branch": "master", "commit": "eae0d8fbde590b0eaa2f9481948cd6fd7dd21656" }, + "telescope.nvim": { "branch": "master", "commit": "dc6fc321a5ba076697cca89c9d7ea43153276d81" }, "tint.nvim": { "branch": "master", "commit": "02bd0527a315a80e4e25bb2dd7b6994fb0daae01" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" }, "typescript-tools.nvim": { "branch": "master", "commit": "f8c2e0b36b651c85f52ad5c5373ff8b07adc15a7" }, - "ui": { "branch": "v3.0", "commit": "0e768898ceabbcbedaae34b0d61b6239ec1362d3" }, + "ui": { "branch": "v3.0", "commit": "32f7f76044e73eedcd1c8a3638a3783b35907e8a" }, "vim-kitty": { "branch": "main", "commit": "9cc594a634308aa3bfaf3da5b5e741da1c0144c1" }, "volt": { "branch": "main", "commit": "43f72b49037c191eb3cfe26ba7a5574b4bfce226" }, "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" } diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index a7178f7..1bf65db 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -6,10 +6,13 @@ local lspconfig = require "lspconfig" local servers = { "html", "cssls", "lua_ls", "biome" } local nvlsp = require "nvchad.configs.lspconfig" +vim.lsp.inlay_hint.enable() + for _, lsp in ipairs(servers) do lspconfig[lsp].setup { on_attach = nvlsp.on_attach, on_init = nvlsp.on_init, capabilities = nvlsp.capabilities, + inlay_hints = { enable = true }, } end diff --git a/lua/configs/telescope.lua b/lua/configs/telescope.lua index dfef785..88654bf 100644 --- a/lua/configs/telescope.lua +++ b/lua/configs/telescope.lua @@ -1,3 +1,5 @@ +dofile(vim.g.base46_cache .. "telescope") + local options = { pickers = { colorscheme = { enable_preview = true }, @@ -17,6 +19,26 @@ local options = { sort_mru = true, }, }, + defaults = { + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + sorting_strategy = "ascending", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + }, + width = 0.87, + height = 0.80, + }, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, + + extensions_list = { "themes", "terms" }, + extensions = {}, } return options diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index e0eabdd..895a931 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,13 +1,34 @@ return { + { "nvim-telescope/telescope.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + cmd = "Telescope", opts = function() - require "configs.telescope" + return require "configs.telescope" end, keys = { - { "", require("telescope.builtin").find_files, desc = "Find Files (root dir)" }, - { "", require("telescope.builtin").live_grep, desc = "Fast live grep" }, - { "", require("telescope.builtin").grep_string, desc = "Fast string grep" }, + { + "", + function() + require("telescope.builtin").find_files() + end, + desc = "File files", + }, + { + "", + function() + require("telescope.builtin").grep_string { search = "" } + end, + desc = "Fuzzy search", + }, + { + "", + function() + require("telescope.builtin").live_grep() + end, + desc = "Grep string", + }, }, }, } diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua new file mode 100644 index 0000000..9612446 --- /dev/null +++ b/lua/plugins/theme.lua @@ -0,0 +1,27 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, + init = function() + vim.cmd.colorscheme "catppuccin-mocha" + require("catppuccin").setup { + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + }, + } + end, + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index d761cf8..736164e 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,48 +1,90 @@ return { { - "nvim-treesitter/nvim-treesitter", - dependencies = { - "JoosepAlviste/nvim-ts-context-commentstring", - "nvim-treesitter/nvim-treesitter-textobjects", - }, - opts = { - ensure_installed = { - "vim", + "nvim-treesitter/nvim-treesitter", + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + opts = { + ensure_installed = { + "vim", "lua", "vimdoc", "html", "css", - "rust", - "regex", - "javascript", - "typescript", - "tsx", - "solidity", - "toml", - "bash", - "markdown", - "markdown_inline", - "json", - "elixir", - "erlang", - "eex", - "kdl", - "yuck", - "sql", - "typst" - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { enable = true }, - }, - }, + "rust", + "regex", + "javascript", + "typescript", + "tsx", + "solidity", + "toml", + "bash", + "markdown", + "markdown_inline", + "json", + "elixir", + "erlang", + "eex", + "kdl", + "yuck", + "sql", + "typst", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + highlight = { enable = true }, + textobjects = { + lsp_interop = { + enable = true, + peek_definition_code = { + ["df"] = "@function.outer", + ["dc"] = "@class.outer", + }, + }, + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@function.outer", + ["ic"] = "@function.inner", + ["ae"] = "@block.outer", + ["ie"] = "@block.inner", + ["as"] = "@statement.outer", + ["is"] = "@statement.inner", + ["am"] = "@call.outer", + ["im"] = "@call.inner", + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]m"] = "@function.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + }, + }, + }, + }, }, }