From 62b04df14509cdee38fb9bd84a1aa64bb7082685 Mon Sep 17 00:00:00 2001 From: Jules Sang Date: Wed, 4 Oct 2023 20:55:01 +0200 Subject: [PATCH] Stuff --- lua/config/autocmds.lua | 7 ++++ lua/config/lazy.lua | 1 + lua/plugins/highlight-colors.lua | 4 ++ lua/plugins/leap-ast.lua | 18 ++++----- lua/plugins/lsp-config.lua | 49 ++++++++++++++++++++++- lua/plugins/null-ls.lua | 18 ++++++++- lua/plugins/nvim-cmp.lua | 14 +++++++ lua/plugins/prettier.lua | 20 +++++++++ lua/plugins/project.lua | 12 ++++++ lua/plugins/tailwindcss-colorizer-cmp.lua | 4 ++ 10 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 lua/plugins/highlight-colors.lua create mode 100644 lua/plugins/nvim-cmp.lua create mode 100644 lua/plugins/prettier.lua create mode 100644 lua/plugins/project.lua create mode 100644 lua/plugins/tailwindcss-colorizer-cmp.lua diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 3302a5f..8a9a186 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -1,3 +1,10 @@ -- Autocmds are automatically loaded on the VeryLazy event -- Default autocmds that are always set: https://github.com/jul-o/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua -- Add any additional autocmds here + +-- vim.api.nvim_create_autocmd({ "BufWritePre" }, { +-- group = vim.api.nvim_create_augroup("format_on_save", {}), +-- callback = function() +-- vim.lsp.buf.format() +-- end, +-- }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 197123a..30bbae9 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -15,6 +15,7 @@ require("lazy").setup({ -- import any extras modules here { import = "lazyvim.plugins.extras.lang.typescript" }, { import = "lazyvim.plugins.extras.lang.json" }, + { import = "lazyvim.plugins.extras.lang.tailwind" }, -- { import = "lazyvim.plugins.extras.ui.mini-animate" }, -- import/override with your plugins { import = "plugins" }, diff --git a/lua/plugins/highlight-colors.lua b/lua/plugins/highlight-colors.lua new file mode 100644 index 0000000..3f9b153 --- /dev/null +++ b/lua/plugins/highlight-colors.lua @@ -0,0 +1,4 @@ +return { + "brenoprata10/nvim-highlight-colors", + config = {}, +} diff --git a/lua/plugins/leap-ast.lua b/lua/plugins/leap-ast.lua index 413ebc2..82c5465 100644 --- a/lua/plugins/leap-ast.lua +++ b/lua/plugins/leap-ast.lua @@ -1,11 +1,11 @@ return { - "jul-o/leap-ast.nvim", - -- dir = '~/projects/nvim-plugins/leap-ast.nvim', - dependencies = { - "ggandor/leap.nvim", - "nvim-treesitter/nvim-treesitter", - }, - config = function() - vim.keymap.set({ "n", "x", "o" }, "s", require("leap-ast").leap, { desc = "Leap AST" }) - end, + -- "jul-o/leap-ast.nvim", + -- -- dir = '~/projects/nvim-plugins/leap-ast.nvim', + -- dependencies = { + -- "ggandor/leap.nvim", + -- "nvim-treesitter/nvim-treesitter", + -- }, + -- config = function() + -- vim.keymap.set({ "n", "x", "o" }, "s", require("leap-ast").leap, { desc = "Leap AST" }) + -- end, } diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua index 4600a87..2302d93 100644 --- a/lua/plugins/lsp-config.lua +++ b/lua/plugins/lsp-config.lua @@ -1,7 +1,46 @@ return { "neovim/nvim-lspconfig", opts = { - servers = { eslint = {} }, + servers = { + tailwindcss = { + filetypes_exclude = { "markdown" }, + }, + eslint = {}, + emmet_language_server = { + filetypes = { + "css", + "eruby", + "html", + "javascript", + "javascriptreact", + "less", + "sass", + "scss", + "svelte", + "pug", + "typescriptreact", + "vue", + }, + -- Read more about this options in the [vscode docs](https://code.visualstudio.com/docs/editor/emmet#_emmet-configuration). + -- **Note:** only the options listed in the table are supported. + init_options = { + --- @type string[] + excludeLanguages = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/preferences/) + preferences = {}, + --- @type boolean Defaults to `true` + showAbbreviationSuggestions = true, + --- @type "always" | "never" Defaults to `"always"` + showExpandedAbbreviation = "always", + --- @type boolean Defaults to `false` + showSuggestionsAsSnippets = false, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/syntax-profiles/) + syntaxProfiles = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/snippets/#variables) + variables = {}, + }, + }, + }, setup = { eslint = function() require("lazyvim.util").on_attach(function(client) @@ -12,6 +51,14 @@ return { end end) end, + + tailwindcss = function(_, opts) + local tw = require("lspconfig.server_configurations.tailwindcss") + --- @param ft string + opts.filetypes = vim.tbl_filter(function(ft) + return not vim.tbl_contains(opts.filetypes_exclude or {}, ft) + end, tw.default_config.filetypes) + end, }, }, } diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index ae7a335..f582a79 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -1,7 +1,23 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + return { "jose-elias-alvarez/null-ls.nvim", opts = function(_, opts) local nls = require("null-ls") - table.insert(opts.sources, nls.builtins.formatting.prettierd) + -- table.insert(opts.sources, nls.builtins.formatting.prettierd) end, + config = { + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + end + end, + }, } diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..65bc924 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,14 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + { "roobert/tailwindcss-colorizer-cmp.nvim", config = true }, + }, + opts = function(_, opts) + -- original LazyVim kind icon formatter + local format_kinds = opts.formatting.format + opts.formatting.format = function(entry, item) + format_kinds(entry, item) -- add icons + return require("tailwindcss-colorizer-cmp").formatter(entry, item) + end + end, +} diff --git a/lua/plugins/prettier.lua b/lua/plugins/prettier.lua new file mode 100644 index 0000000..0fb82fe --- /dev/null +++ b/lua/plugins/prettier.lua @@ -0,0 +1,20 @@ +return { + "MunifTanjim/prettier.nvim", + config = { + bin = "prettier", -- or `'prettierd'` (v0.23.3+) + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + }, + }, +} diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua new file mode 100644 index 0000000..24525b9 --- /dev/null +++ b/lua/plugins/project.lua @@ -0,0 +1,12 @@ +return { + "ahmedkhalf/project.nvim", + opts = {}, + event = "VeryLazy", + config = function(_, opts) + require("project_nvim").setup(opts) + require("telescope").load_extension("projects") + end, + keys = { + { "fp", "Telescope projects", desc = "Projects" }, + }, +} diff --git a/lua/plugins/tailwindcss-colorizer-cmp.lua b/lua/plugins/tailwindcss-colorizer-cmp.lua new file mode 100644 index 0000000..394bc55 --- /dev/null +++ b/lua/plugins/tailwindcss-colorizer-cmp.lua @@ -0,0 +1,4 @@ +return { + "roobert/tailwindcss-colorizer-cmp.nvim", + config = true, +}