wkillerud / some-sass

Improved support for SCSS, Sass indented and SassDoc. Workspace awareness and full support for Sass modules.
https://wkillerud.github.io/some-sass/
61 stars 6 forks source link

Doesn't work #175

Closed xndrpr closed 5 months ago

xndrpr commented 5 months ago

NeoVim 0.10.0 Lazy.nvim

Hi! I really like your lsp, however it doesn't seem to work on my machine. I am pretty sure the problem is with the way I configured my neovim, because on astronvim it worked. I want to make my own config, but it is impossible (for me) without having autocomplete for scss files.

Could you help me please?

Here is my config:

lua/plugins/lsp.lua

return {
  { "williamboman/mason.nvim", config = function() require("mason").setup() end },
  {
    "williamboman/mason-lspconfig.nvim",
    config = function()
      require("mason-lspconfig").setup {
        ensure_installed = {
          "lua_ls",
          "tsserver",
          "jsonls",
          "tailwindcss",
          "rust_analyzer",
          "pyright",
          "cssls",
          "cssmodules_ls",
          "somesass_ls"
        },
      }
    end,
  },
  {
    "neovim/nvim-lspconfig",
    config = function()
      local lspconfig = require "lspconfig"
      local capabilities = vim.lsp.protocol.make_client_capabilities()
      capabilities.textDocument.completion.completionItem.snippetSupport = true

      lspconfig.emmet_ls.setup {
        capabilities = capabilities,
        filetypes = {
          "css",
          "eruby",
          "html",
          "less",
          "sass",
          "scss",
          "svelte",
          "pug",
          "vue",
        },
        init_options = {
          html = {
            options = {
              ["bem.enabled"] = true,
            },
          },
        },
      }
      lspconfig.lua_ls.setup {}
      lspconfig.tsserver.setup {}
      lspconfig.jsonls.setup {}
      lspconfig.tailwindcss.setup {}
      lspconfig.rust_analyzer.setup {}
      lspconfig.pyright.setup {}
      lspconfig.cssls.setup {}
      lspconfig.cssmodules_ls.setup {}
      lspconfig.somesass_ls.setup {}

      vim.keymap.set("n", "<leader>q", vim.lsp.buf.hover, {})
      vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
      vim.keymap.set({ "n" }, "<leader>ca", vim.lsp.buf.code_action, {})
    end,
  },
}

lua/plugins/cmp.lua

return {
  "hrsh7th/nvim-cmp",
  event = { "InsertEnter", "CmdlineEnter" },
  dependencies = {
    "hrsh7th/cmp-buffer",
    "hrsh7th/cmp-path",
    "L3MON4D3/LuaSnip",
    "saadparwaizl/cmp_luasnip",
    "rafamadriz/friendly-snippets",
    "onsails/lspkind.nvim",
  },

  config = function()
    local ls = require "luasnip"
    local s = ls.snippet
    local t = ls.text_node
    local i = ls.insert_node

    ls.add_snippets("typescriptreact", {
      s("class", {
        t 'className="',
        i(1, ""),
        t '"',
      }),
    })
    local cmp = require "cmp"
    local luasnip = require "luasnip"
    local lspkind = require "lspkind"

    require("luasnip.loaders.from_vscode").lazy_load()

    cmp.setup({
      completion = {
        completeopt = "menu,menuone,preview,noselect"
      },
      snippet = {
        expand = function(args)
          luasnip.lsp_expand(args.body)
        end
      },
      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 }),

        ["<Tab>"] = cmp.mapping(function(fallback)
          if cmp.visible() then
            cmp.select_next_item()
          elseif luasnip.locally_jumpable(1) then
            luasnip.jump(1)
          else
            fallback()
          end
        end, { "i", "s" }),

        ["<S-Tab>"] = cmp.mapping(function(fallback)
          if cmp.visible() then
            cmp.select_prev_item()
          elseif luasnip.locally_jumpable(-1) then
            luasnip.jump(-1)
          else
            fallback()
          end
        end, { "i", "s" }),
      }),
      sources = {
        { name = "nvim_lsp" },
        { name = "luasnip" },
        { name = "buffer" },
        { name = "path" }
      },
      formatting = {
        format = require("tailwindcss-colorizer-cmp").formatter,
      },
    })
  end
}
xndrpr commented 5 months ago

https://github.com/wkillerud/some-sass/assets/98014243/c47627f3-30c6-4951-9cf4-d1be6da20de1

xndrpr commented 5 months ago

Switched to lsp-zero and it works now