diff --git a/init.lua b/init.lua index 14c6281..4bb38a4 100644 --- a/init.lua +++ b/init.lua @@ -13,6 +13,8 @@ vim.keymap.set({ "n", "v" }, "", "") vim.keymap.set({ "n", "i" }, "", ":w") +vim.filetype.add { extension = { templ = "templ" } } + local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then vim.fn.system { @@ -55,4 +57,5 @@ vim.o.number = true -- vim.schedule(function() require "options" require "remaps" +require "autocmd" -- end) diff --git a/lazy-lock.json b/lazy-lock.json index 158784a..702a99c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,11 +6,15 @@ "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-nvim-ultisnips": { "branch": "main", "commit": "24bca5c3e137b28cd87442d4fc51a2b312dd99cc" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "820eec990d5f332d30cf939954c8672a43a0459e" }, + "cyberdream.nvim": { "branch": "main", "commit": "b4c594999649584e1176c84a0f617ba1f91ab2eb" }, "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" }, "gitsigns.nvim": { "branch": "main", "commit": "d96ef3bbff0bdbc3916a220f5c74a04c4db033f2" }, + "go.nvim": { "branch": "master", "commit": "591a0b837420f27c734600fa5c6de87f18352e50" }, + "guihua.lua": { "branch": "master", "commit": "3b3126ae87c254f6849e708549ba76c39e3f42f8" }, "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, "kanagawa.nvim": { "branch": "master", "commit": "bfa818c7bf6259152f1d89cf9fbfba3554c93695" }, "lazy.nvim": { "branch": "main", "commit": "31ddbea7c10b6920c9077b66c97951ca8682d5c8" }, diff --git a/lua/autocmd.lua b/lua/autocmd.lua new file mode 100644 index 0000000..b38bfc1 --- /dev/null +++ b/lua/autocmd.lua @@ -0,0 +1 @@ +-- vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = { "*.templ" }, callback = vim.lsp.buf.format }) diff --git a/lua/configs/cmp.lua b/lua/configs/cmp.lua new file mode 100644 index 0000000..2dfbe43 --- /dev/null +++ b/lua/configs/cmp.lua @@ -0,0 +1,117 @@ +local cmp = require "cmp" + +-- dofile(vim.g.base46_cache .. "cmp") + +local cmp_ui = require("nvconfig").ui.cmp +local cmp_style = cmp_ui.style + +local field_arrangement = { + atom = { "kind", "abbr", "menu" }, + atom_colored = { "kind", "abbr", "menu" }, +} + +local formatting_style = { + -- default fields order i.e completion word + item.kind + item.kind icons + fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" }, + + format = function(_, item) + local icons = require "nvchad.icons.lspkind" + local icon = (cmp_ui.icons and icons[item.kind]) or "" + + if cmp_style == "atom" or cmp_style == "atom_colored" then + icon = " " .. icon .. " " + item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or "" + item.kind = icon + else + icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon + item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "") + end + + return item + end, +} + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +local options = { + completion = { + completeopt = "menu,menuone", + }, + + window = { + completion = { + side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0, + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", + scrollbar = false, + }, + documentation = { + border = border "CmpDocBorder", + winhighlight = "Normal:CmpDoc", + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = formatting_style, + + -- mapping = { + -- [""] = cmp.mapping.select_prev_item(), + -- [""] = cmp.mapping.select_next_item(), + -- [""] = cmp.mapping.scroll_docs(-4), + -- [""] = cmp.mapping.scroll_docs(4), + -- [""] = cmp.mapping.complete(), + -- [""] = cmp.mapping.close(), + -- + -- [""] = cmp.mapping.confirm { + -- behavior = cmp.ConfirmBehavior.Insert, + -- select = true, + -- }, + -- + -- [""] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif require("luasnip").expand_or_jumpable() then + -- vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + -- else + -- fallback() + -- end + -- end, { "i", "s" }), + -- + -- [""] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_prev_item() + -- elseif require("luasnip").jumpable(-1) then + -- vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + -- else + -- fallback() + -- end + -- end, { "i", "s" }), + -- }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then + options.window.completion.border = border "CmpBorder" +end + +return options diff --git a/lua/configs/treesitter.lua b/lua/configs/treesitter.lua index e3f936c..dd7e326 100644 --- a/lua/configs/treesitter.lua +++ b/lua/configs/treesitter.lua @@ -16,6 +16,7 @@ return { "css", "astro", "bash", + "templ", }, -- highlight = { -- enable = true, diff --git a/lua/options.lua b/lua/options.lua index 5422690..426f97b 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -69,4 +69,4 @@ vim.api.nvim_create_autocmd("TextYankPost", { }) -- set colorscheme -vim.cmd.colorscheme "catppuccin-mocha" +vim.cmd.colorscheme "cyberdream" diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index a9eae77..0f84293 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -13,7 +13,7 @@ return { bash = { "shfmt" }, sh = { "shfmt" }, lua = { "stylua" }, - go = { "goimports", "gofumpt", "goimports-reviser" }, + go = { "goimports", "gofumpt" }, javascript = { { "prettierd", "prettier" } }, typescript = { { "prettierd", "prettier" } }, javascriptreact = { { "prettierd", "prettier" } }, diff --git a/lua/plugins/go.lua b/lua/plugins/go.lua new file mode 100644 index 0000000..5189f2d --- /dev/null +++ b/lua/plugins/go.lua @@ -0,0 +1,14 @@ +return { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = { "CmdlineEnter" }, + ft = { "go", "gomod" }, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries +} diff --git a/lua/plugins/lsp-zero.lua b/lua/plugins/lsp-zero.lua index 9970ecd..0dce2b0 100644 --- a/lua/plugins/lsp-zero.lua +++ b/lua/plugins/lsp-zero.lua @@ -28,6 +28,10 @@ return { "clangd", "lua_ls", "pyright", + "html", + "htmx", + "emmet_ls", + "templ", }, handlers = { function(server_name) @@ -39,6 +43,36 @@ return { }, }, } + require("lspconfig").emmet_ls.setup { + -- on_attach = on_attach, + capabilities = capabilities, + filetypes = { + "css", + "eruby", + "html", + "javascript", + "javascriptreact", + "less", + "sass", + "scss", + "svelte", + "pug", + "typescriptreact", + "vue", + "templ", + }, + init_options = { + html = { + options = { + -- For possible options, see: https://github.com/emmetio/emmet/blob/master/src/config.ts#L79-L267 + ["bem.enabled"] = true, + }, + }, + }, + } + require("lspconfig").htmx.setup { + filetypes = { "html", "templ" }, + } end, }, } diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua index 312b82e..851167f 100644 --- a/lua/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -1,5 +1,11 @@ return { "hrsh7th/nvim-cmp", + opts = function() + require "configs.cmp" + end, + config = function(_, opts) + require("cmp").setup(opts) + end, dependencies = { { -- snippet plugin @@ -11,6 +17,12 @@ return { require "configs.luasnip" end, }, + { + "quangnguyen30192/cmp-nvim-ultisnips", + config = function() + require("cmp_nvim_ultisnips").setup {} + end, + }, -- autopairing of (){}[] etc { @@ -32,6 +44,7 @@ return { { "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", }, diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 620c7b9..deae5b2 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -5,12 +5,9 @@ return { dependencies = { "nvim-tree/nvim-web-devicons", lazy = true, - opts = function() - return { override = require "nvchad.icons.devicons" } - end, - opts = function() - require "configs.nvim-tree" - end, + -- opts = function() + -- return { override = require "nvchad.icons.devicons" } + -- end, config = function(_, opts) -- dofile(vim.g.base46_cache .. "devicons") require("nvim-web-devicons").setup(opts) diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua new file mode 100644 index 0000000..bcb67d8 --- /dev/null +++ b/lua/plugins/themes.lua @@ -0,0 +1,18 @@ +return { + { + "scottmckendry/cyberdream.nvim", + lazy = false, + priority = 1000, + config = function() + require("cyberdream").setup { + -- Recommended - see "Configuring" below for more config options + transparent = true, + italic_comments = true, + hide_fillchars = true, + -- borderless_telescope = true, + terminal_colors = true, + } + vim.cmd "colorscheme cyberdream" -- set the colorscheme + end, + }, +} diff --git a/lua/remaps.lua b/lua/remaps.lua index 95400cc..0a1f4b9 100644 --- a/lua/remaps.lua +++ b/lua/remaps.lua @@ -10,6 +10,7 @@ map("n", "", "k", { desc = "Switch Window up" }) map("n", "qq", ":wa:qa") map("i", "jk", "") map("n", "b", "") +map("n", "m", ":!") -- telescope keybinds local builtin = require "telescope.builtin"