From c86e696728069adcd895314762bded67a8764c9e Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 28 May 2024 11:37:18 +0930 Subject: [PATCH] feat: add flash.nvim --- .config/nvim/lua/tovi/core/options.lua | 1 + .config/nvim/lua/tovi/plugins/flash.lua | 14 ++++++++++++++ .../nvim/lua/tovi/plugins/lsp/lspconfig.lua | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .config/nvim/lua/tovi/plugins/flash.lua diff --git a/.config/nvim/lua/tovi/core/options.lua b/.config/nvim/lua/tovi/core/options.lua index b7a066d..ee100ec 100644 --- a/.config/nvim/lua/tovi/core/options.lua +++ b/.config/nvim/lua/tovi/core/options.lua @@ -44,3 +44,4 @@ vim.opt.splitright = true vim.opt.termguicolors = true +vim.opt.cursorline = true diff --git a/.config/nvim/lua/tovi/plugins/flash.lua b/.config/nvim/lua/tovi/plugins/flash.lua new file mode 100644 index 0000000..e707ee9 --- /dev/null +++ b/.config/nvim/lua/tovi/plugins/flash.lua @@ -0,0 +1,14 @@ +return { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, +} diff --git a/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua b/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua index 5cd5ae2..405fb6a 100644 --- a/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua +++ b/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua @@ -88,6 +88,7 @@ return { -- override default floating window border if not set local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview + ---@diagnostic disable-next-line: duplicate-set-field function vim.lsp.util.open_floating_preview(contents, syntax, options, ...) options = options or {} options.border = options.border or "rounded" @@ -112,6 +113,9 @@ return { -- Function to detect the operating system local function get_os() local handle = io.popen('uname') + if not handle then + return error("Failed to detect operating system") + end local result = handle:read("*a") handle:close() return result:lower():gsub("%s+", "") @@ -165,7 +169,11 @@ return { lspconfig.volar.setup({ -- capabilities = capabilities, on_attach = on_attach, - filetypes = { "vue" }, + filetypes = { + "javascript", + "typescript", + "vue", + }, on_new_config = function(new_config, new_root_dir) new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) end, @@ -180,11 +188,12 @@ return { -- configure php server lspconfig["intelephense"].setup({ root_dir = function(pattern) - local cwd = vim.loop.cwd() - local root = util.root_pattern('composer.json')(pattern) + ---@diagnostic disable-next-line: undefined-field + local cwd = vim.loop.cwd() + local root = util.root_pattern('composer.json')(pattern) - -- prefer cwd if root is a descendant - return util.path.is_descendant(cwd, root) and cwd or root + -- prefer cwd if root is a descendant + return util.path.is_descendant(cwd, root) and cwd or root end, capabilities = capabilities, on_attach = on_attach,