Skip to content

Instantly share code, notes, and snippets.

@Jezda1337
Created October 26, 2023 20:46
Show Gist options
  • Save Jezda1337/d74c22070e523a59885ba4d3c71af2dd to your computer and use it in GitHub Desktop.
Save Jezda1337/d74c22070e523a59885ba4d3c71af2dd to your computer and use it in GitHub Desktop.
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use { "Jezda1337/nvim-html-css", requires = { "nvim-treesitter/nvim-treesitter", "nvim-lua/plenary.nvim" } }
use "nvim-treesitter/nvim-treesitter"
use 'neovim/nvim-lspconfig'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'hrsh7th/nvim-cmp'
use 'L3MON4D3/LuaSnip'
if packer_bootstrap then
require('packer').sync()
end
end)
local cmp = require 'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
formatting = {
format = function(entry, vim_item)
if entry.source.name == "html-css" then
vim_item.menu = entry.completion_item.menu
end
return vim_item
end
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{
name = "html-css",
option = {
enable_on = {
"html"
}, -- set the file types you want the plugin to work on
file_extensions = { "css", "sass", "less" }, -- set the local filetypes from which you want to derive classes
style_sheets = {
-- example of remote styles, only css no js for now
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css",
"https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css",
}
}
},
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
require('html-css'):setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment