diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 2b6a2f4..74a2753 100755 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -135,11 +135,17 @@ return { on_attach = on_attach, }) - lspconfig.volar.setup({ - capabilities = capabilities, - on_attach = on_attach, - cmd = { "vue-language-server", "--stdio" } - }) + -- lspconfig.volar.setup({ + -- capabilities = capabilities, + -- on_attach = on_attach, + -- cmd = { "vue-language-server", "--stdio" }, + -- filetypes = { "vue" }, + -- settings = { + -- typescript = { + -- tsdk = '/usr/lib/node_modules/typescript/lib' + -- } + -- } + -- }) -- done in ftplugin lspconfig.jdtls.setup({ diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index d238c1e..222123d 100755 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -32,6 +32,7 @@ return { -- "lua_ls", -- "pyright", -- "tsserver", + "volar" }, -- auto-install configured servers (with lspconfig) automatic_installation = true, diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 4d7505e..f97ef17 100755 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,3 +1,50 @@ +local actions = require('telescope.actions') +local action_state = require('telescope.actions.state') + +-- Custom function for search and replace using Telescope +-- test +function _G.search_and_replace() + local current_file = vim.fn.expand('%:p') + local query = vim.fn.input('Enter search pattern: ') + + -- Create the Telescope prompt with custom mappings + require('telescope.builtin').find_files({ + prompt_title = 'Search and Replace', + cwd = vim.loop.cwd(), + hidden = true, + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + local selection = action_state.get_selected_entry() + + -- Get the replace pattern from user + local replace_query = vim.fn.input('Replace with: ', '') + + if not replace_query == '' then + local args = { query, replace_query } + + -- Open a terminal buffer to run the search and replace command + require('telescope.builtin').terminal_job({ + cmd = { + 'sh', '-c', + string.format( + "grep -rl '%s' . | xargs sed -i 's/%s/%s/g'", + table.concat(args, "'"), + query, + replace_query + ) + }, + cwd = vim.fn.expand('%:p:h'), + }) + end + + return true + end) + + return true + end + }) +end + return { -- fuzzy finder "nvim-telescope/telescope.nvim",