folke / todo-comments.nvim

✅ Highlight, list and search todo comments in your projects
Apache License 2.0
3.12k stars 88 forks source link

Not working with `.norg` filetype? #106

Closed xfzv closed 1 year ago

xfzv commented 2 years ago

I've started using Neorg lately. Comments in .norg files can be inserted with +comment+. I'm not sure if I missed something but todo-comments.nvim doesn't seem to work with .norg filetype, although it works just fine for other languages:

Any idea?

Thanks!

mrossinek commented 2 years ago

I just ran into the same issue. It appears that this is due to the fact that this plugin checks for the specific node name comment, which we so far do not use in Neorg. I just pushed a fix for that to Neorg main so you should be able to use this as expected now :+1:

xfzv commented 2 years ago

I just ran into the same issue. It appears that this is due to the fact that this plugin checks for the specific node name comment, which we so far do not use in Neorg. I just pushed a fix for that to Neorg main so you should be able to use this as expected now +1

Thank you! Can confirm that it now works as expected:

image

@TODO and @hack aren't highlighted though (works with other file types) but it's not a big deal. Maybe you can find a workaround too on Neorg side so I'll just close this.

MyraBaba commented 2 years ago

@xfzv

I updated the neorg but still not seen the colours as above

Screen Shot 2022-05-20 at 16 30 42
max397574 commented 2 years ago

did u also update the parser?

MyraBaba commented 2 years ago

@xfzv I just re install the neorg which comes with the updated highlights.scm

what else do I need to do and how :)

max397574 commented 2 years ago

update the parser

MyraBaba commented 2 years ago

@xfzv parser you mean todo-comment ?

sorry I am a newbie on neovim. trying to leave Qt / VSCode for c++

MyraBaba commented 2 years ago

@xfzv if you mean .

:Neorg sync-parsers

its not available in my config.

max397574 commented 2 years ago

:TSUpdate norg

MyraBaba commented 2 years ago

@xfzv

It says parsers update but still not working.

here my config:


> 
--[[
lvim is the global options object

Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT

-- general
vim.opt.smartindent = true
vim.opt.cursorcolumn = true
lvim.log.level = "warn"
lvim.format_on_save = true
lvim.colorscheme = "tokyonight"
-- to disable icons and use a minimalist setup, uncomment the following
-- lvim.use_icons = false

-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = "space"

-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- unmap a default keymapping
-- lvim.keys.normal_mode["<C-Up>"] = false
-- edit a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>"

-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
-- local _, actions = pcall(require, "telescope.actions")
-- lvim.builtin.telescope.defaults.mappings = {
--   -- for input mode
--   i = {
--     ["<C-j>"] = actions.move_selection_next,
--     ["<C-k>"] = actions.move_selection_previous,
--     ["<C-n>"] = actions.cycle_history_next,
--     ["<C-p>"] = actions.cycle_history_prev,
--   },
--   -- for normal mode
--   n = {
--     ["<C-j>"] = actions.move_selection_next,
--     ["<C-k>"] = actions.move_selection_previous,
--   },
-- }

-- Use which-key to add extra bindings with the leader-key prefix
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" }
-- lvim.builtin.which_key.mappings["t"] = {
--   name = "+Trouble",
--   r = { "<cmd>Trouble lsp_references<cr>", "References" },
--   f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
--   d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" },
--   q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
--   l = { "<cmd>Trouble loclist<cr>", "LocationList" },
--   w = { "<cmd>Trouble workspace_diagnostics<cr>", "Wordspace Diagnostics" },
-- }

-- TODO: User Config for predefined plugins
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.notify.active = true
lvim.builtin.terminal.active = true
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.show_icons.git = 0
lvim.builtin.dap.active = true
-- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
  "bash",
  "c",
  "javascript",
  "json",
  "lua",
  "python",
  "typescript",
  "tsx",
  "css",
  "rust",
  "java",
  "yaml",
}

lvim.builtin.treesitter.ignore_install = { "haskell" }
lvim.builtin.treesitter.highlight.enabled = true

local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()

parser_configs.norg = {
  install_info = {
    url = "https://github.com/nvim-neorg/tree-sitter-norg",
    files = { "src/parser.c", "src/scanner.cc" },
    branch = "main"
  },
}

require('nvim-treesitter.configs').setup {
  ensure_installed = { "norg", "cpp", "c", "python" },
  highlight = { -- Be sure to enable highlights if you haven't!
    enable = true,
  }
}
-- generic LSP settings

-- ---@usage disable automatic installation of servers
lvim.lsp.automatic_servers_installation = true

-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!!
-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))`
-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
-- local opts = {} -- check the lspconfig documentation for a list of all possible options
-- require("lvim.lsp.manager").setup("pyright", opts)

-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!!
-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype
-- vim.tbl_map(function(server)
--   return server ~= "emmet_ls"
-- end, lvim.lsp.automatic_configuration.skipped_servers)

-- -- you can set a custom on_attach function that will be used for all the language servers
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
-- lvim.lsp.on_attach_callback = function(client, bufnr)
--   local function buf_set_option(...)
--     vim.api.nvim_buf_set_option(bufnr, ...)
--   end
--   --Enable completion triggered by <c-x><c-o>
--   buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- end

-- -- set a formatter, this will override the language server formatting capabilities (if it exists)
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })

local clangd_bin = "/Users/tulpar/.local/share/nvim/lsp_servers/clangd/clangd/bin/clangd"
-- some settings can only passed as commandline flags `clangd --help`
local clangd_flags = {
  "--all-scopes-completion",
  "--suggest-missing-includes",
  "--background-index",
  "--pch-storage=disk",
  "--cross-file-rename",
  "--log=verbose",
  "--completion-style=detailed",
  "--enable-config", -- clangd 11+ supports reading from .clangd configuration file
  "--clang-tidy",
  --"--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type",
  --"--compile-commands-dir=/Users/tulpar/Projects/BClite-AI/",
  -- "--fallback-style=Google",
  -- "--header-insertion=never",
  -- "--query-driver=<list-of-white-listed-complers>"
}

local custom_on_attach = function(client, bufnr)
  require("lvim.lsp").common_on_attach(client, bufnr)
  local opts = { noremap = true, silent = true }
  vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>lh", "<Cmd>ClangdSwitchSourceHeader<CR>", opts)
end

local opts = {
  cmd = { clangd_bin, unpack(clangd_flags) },
  on_attach = custom_on_attach,
}

require("lvim.lsp.manager").setup("clangd", opts)

local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
  { command = "black", filetypes = { "python" } },
  { command = "isort", filetypes = { "python" } },
  {
    -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
    command = "prettier",
    ---@usage arguments to pass to the formatter
    -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
    extra_args = { "--print-with", "100" },
    ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
    filetypes = { "typescript", "typescriptreact" },
  },
}

-- -- set additional linters
local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
  { command = "flake8", filetypes = { "python" } },
  {
    -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
    command = "shellcheck",
    ---@usage arguments to pass to the formatter
    -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
    extra_args = { "--severity", "warning" },
  },
  {
    command = "codespell",
    ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
    filetypes = { "javascript", "python" },
  },
}
--FIXME
-- FIX:
-- HACK:
-- @TODO:

--HACK:
--PERF:
-- Additional Plugins
lvim.plugins = {
  { "folke/tokyonight.nvim" },
  { "lunarvim/colorschemes" },
  { "arcticicestudio/nord-vim" },
  { "mg979/vim-visual-multi",
    branch = 'master' },
  {
    "folke/trouble.nvim",
    cmd = "TroubleToggle",
  },
  {
    "folke/todo-comments.nvim",
    event = "BufRead",
    signs = true, -- show icons in the signs column
    sign_priority = 8, -- sign priority
    config = function()
      require("todo-comments").setup()
    end,
  },

  {
    "nvim-neorg/neorg",
    tag = "*",
    config = function()
      require('neorg').setup {
        load = {
          ["core.defaults"] = {},
          ["core.norg.concealer"] = {}, -- Allows for use of icons
          ["core.gtd.ui"] = {
            config = { -- Note that this table is optional and doesn't need to be provided
              -- Configuration here
            }
          },
          ["core.keybinds"] = { -- Configure core.keybinds
            config = {
              default_keybinds = true, -- Generate the default keybinds
              neorg_leader = "<Leader>o"
            }
          },

          ["core.gtd.helpers"] = {},
          ["core.gtd.queries"] = {},
          ["core.norg.qol.toc"] = {
            config = { -- Note that this table is optional and doesn't need to be provided
              -- Configuration here
            }
          },
          ["core.norg.completion"] = {
            config = { -- Note that this table is optional and doesn't need to be provided
              engine = "nvim-cmp"

            }
          },
          ["core.highlights"] = {
            config = {}
          },
          ["core.norg.dirman"] = {
            config = {
              workspaces = {
                work = "~/neorg/work",
                home = "~/neorg/home",
                gtd  = "~/neorg/gtd"
              },
              index = "index.norg",
              autochdir = true,

            }
          },
          ["core.gtd.base"] = {
            config = {
              workspace = "gtd",
            },
          },
        }

      }
    end,
    requires = "nvim-lua/plenary.nvim"

  },
  {
    "itchyny/vim-cursorword",
    event = { "BufEnter", "BufNewFile" },
    config = function()
      vim.api.nvim_command("augroup user_plugin_cursorword")
      vim.api.nvim_command("autocmd!")
      vim.api.nvim_command("autocmd FileType NvimTree,lspsagafinder,dashboard,vista let b:cursorword = 0")
      vim.api.nvim_command("autocmd WinEnter * if &diff || &pvw | let b:cursorword = 0 | endif")
      vim.api.nvim_command("autocmd InsertEnter * let b:cursorword = 0")
      vim.api.nvim_command("autocmd InsertLeave * let b:cursorword = 1")
      vim.api.nvim_command("augroup END")
    end
  },
}
mrossinek commented 2 years ago

I updated the neorg but still not seen the colours as above

Screen Shot 2022-05-20 at 16 30 42

@MyraBaba

Most of those lines are not valid norg syntax. This will likely confuse the parser significantly. So I suggest you try the following contents:

+PERF:+
+HACK:+
+TODO:+
+NOTE:+
+FIX:+
+WARN:+

This should result in something like the following: screenshot_1653221524

Notes/questions:

max397574 commented 2 years ago

works for me as well

MyraBaba commented 2 years ago

After delete and remove norg its now working.

Updating the norg not really pulling the updates.

MyraBaba commented 2 years ago

@mrossinek There is interesting behaviour 👍 in the index.norg all is good and working but other linked norg file not showing the highligts

Best

MyraBaba commented 2 years ago

Here a different error : MAc os X Catalina

install and reinstall many times but not changed. After install it shows highlights and than gives error and stop working.

Screen Shot 2022-05-22 at 18 21 43
xfzv commented 1 year ago

Re-opening because it's no longer working here, not sure when it broke, maybe quite a long time ago.

https://user-images.githubusercontent.com/78810647/195432010-20c542a9-b2fe-4553-bedb-964e0df73d16.mp4

Still working fine for other file types:

image

Anyone else?

max397574 commented 1 year ago

it seems like the first issue again (that the thing isn't called comment) @vhyrro @mrossinek ? Screenshot 2022-10-12 at 21 53 12

max397574 commented 1 year ago

if works for me Screenshot 2022-10-21 at 10 28 25

xfzv commented 1 year ago

if works for me

Still doesn't here. It works in code blocks but not for actual norg comments: image

Have you made any change to Neorg and/or todo-comments config file(s) since your previous message or has it been fixed automagically?

Tried deleting ~∕.local/share/nvim/site/pack/packer/start/{neorg,todo-comments.nvim} but it doesn't make any difference.

require('neorg').setup {
    load = {
        ["core.defaults"] = {},
        ["core.norg.concealer"] = {
            config = {
                dim_code_blocks = {
                    enabled = true,
                    conceal = true,
                    content_only = true,
                    adaptive = true,
                },
                icon_preset = "diamond",
            },
        },
    },
}
require('todo-comments').setup {
}
vim.api.nvim_command('packadd packer.nvim')
function get_setup(name)
  return string.format('require("setup/%s")', name)
end
-- ...
    use { 'folke/todo-comments.nvim', requires = 'nvim-lua/plenary.nvim', config = get_setup('todo-comments') }
    use { 'nvim-neorg/neorg', requires = 'nvim-lua/plenary.nvim', config = get_setup('neorg') }
-- ...
❯ nvim --version
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3

All tree-sitter parsers are up-to-date.

max397574 commented 1 year ago

@xfzv I think this can be closed now?

xfzv commented 1 year ago

@xfzv I think this can be closed now?

Indeed, thanks.