jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
338 stars 26 forks source link

How can I just only highlight the middle of a conditional compilation #87

Open Crazyokd opened 2 months ago

Crazyokd commented 2 months ago

Your plugin was very useful when I used vim+coc+ccls in the past. now I mainly use neovim+ccls because the neovim more fast. I'm mostly using treesitter to provide highlighting because it works so well with my color theme.

When using ccls as my lsp, it doesn't seem to support conditional compilation well enough to provide effective highlighting. image

When I tried vim-lsp-cxx-hight again, I found that it solves the problem effectively. But it also affects the highlighting of other symbols. image

So I would like to be able to enable only macro related highlighting and turn off other settings. I want to know how can I do it?

below is my lsp-config.lua:

return {
  "neovim/nvim-lspconfig",
    dependencies = {
        "hrsh7th/cmp-nvim-lsp",
        {
            "jackguo380/vim-lsp-cxx-highlight",
            ft = { 'c', 'cpp', 'h', 'hpp' }
        }
    },
  config = function()
    local lspconfig = require("lspconfig")
    local capabilities = require("cmp_nvim_lsp").default_capabilities()

    lspconfig.lua_ls.setup {
      capabilities = capabilities,

      settings = {
          Lua = {
              diagnostics = {
                  globals = { "vim" }
              }
          }
      }
    }

    lspconfig.ccls.setup {
      capabilities = capabilities,
      init_options = {
        cache = {
          directory = "/tmp/ccls"
        };
        client = {
          snippetSupport = true
        };
        compilationDatabaseDirectory = "build";
        highlight = {
          lsRanges = true;
        };
        clang = {
          extraArgs = {
            "--query-driver=/usr/bin/gcc,/usr/bin/g++",
            "--gcc-toolchain=/usr",
          };
        };
      }
    }