change copilot plugin and add tailwind plugins

This commit is contained in:
Gustavo Silva (es00679121_prosegur) 2024-02-20 19:18:36 +01:00
parent 63f64af2af
commit d22d6e5acb
7 changed files with 204 additions and 21 deletions

View file

@ -96,11 +96,23 @@ require('lazy').setup({
'hrsh7th/nvim-cmp',
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip',
{
'L3MON4D3/LuaSnip',
build = (function()
-- Build Step is needed for regex support in snippets
-- This step is not supported in many windows environments
-- Remove the below condition to re-enable on windows
if vim.fn.has 'win32' == 1 then
return
end
return 'make install_jsregexp'
end)(),
},
'saadparwaiz1/cmp_luasnip',
-- Adds LSP completion capabilities
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
@ -319,6 +331,42 @@ require('telescope').setup {
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
-- Telescope live_grep in git root
-- Function to find the git root directory based on the current buffer's path
local function find_git_root()
-- Use the current buffer's path as the starting point for the git search
local current_file = vim.api.nvim_buf_get_name(0)
local current_dir
local cwd = vim.fn.getcwd()
-- If the buffer is not associated with a file, return nil
if current_file == '' then
current_dir = cwd
else
-- Extract the directory from the current file's path
current_dir = vim.fn.fnamemodify(current_file, ':h')
end
-- Find the Git root directory from the current file's path
local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
if vim.v.shell_error ~= 0 then
print 'Not a git repository. Searching on current working directory'
return cwd
end
return git_root
end
-- Custom live_grep function to search in git root
local function live_grep_git_root()
local git_root = find_git_root()
if git_root then
require('telescope.builtin').live_grep {
search_dirs = { git_root },
}
end
end
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
@ -329,6 +377,7 @@ vim.keymap.set('n', '<leader>/', function()
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
local function telescope_live_grep_open_files()
require('telescope.builtin').live_grep {
grep_open_files = true,
@ -345,7 +394,6 @@ vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc
vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
-- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
@ -370,11 +418,20 @@ vim.defer_fn(function()
"yaml",
"css",
"html",
"templ",
"terraform",
"hcl"
},
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
-- Install languages synchronously (only applied to `ensure_installed`)
sync_install = false,
-- List of parsers to ignore installing
ignore_install = {},
-- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- },
modules = {},
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
@ -608,14 +665,16 @@ local servers = {
filetypes = { 'templ' },
},
html = {
filetypes = { 'html', 'templ' },
},
htmx = {
filetypes = { 'html', 'templ' },
filetypes = { 'html', 'gohtml', 'templ' },
},
htmx = {},
tailwindcss = {
filetypes = { 'html', 'css', 'scss', 'javascript', 'typescript', 'templ' },
init_options = { userLanguages = { templ = "html" } },
filetypes = { 'html', 'css', 'scss', 'javascript', 'typescript', 'templ', 'gohtml' },
},
tflint = {
},
terraform = {
filetypes = { 'terraform', 'tf', 'tfvars' },
},
}
@ -640,7 +699,7 @@ mason_lspconfig.setup_handlers {
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
init_options = (servers[server_name] or {}).init_options,
-- init_options = (servers[server_name] or {}).init_options,
}
end,
}
@ -658,10 +717,13 @@ cmp.setup {
luasnip.lsp_expand(args.body)
end,
},
completion = {
completeopt = 'menu,menuone,noinsert',
},
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<Down>'] = cmp.mapping.scroll_docs(-4),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
@ -690,6 +752,7 @@ cmp.setup {
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}