Previous Pages

Ctags

You should generate a ctags file with "--excmd=number" for outputting line numbers and use absolute paths. Then put the code in a module or your ~/.textadept/init.lua:

function goto_ctag()
  local file_name, line_num =
    buffer:get_cur_line():match('^%S+\t([^\t]+)\t([^;]+);"\t.+$')
  if file_name and line_num then
    -- Open file in a new split or other existing split.
    if #_VIEWS == 1 then
      _, new_view = view:split(true)
      new_view:focus()
    else
      for i, other_view in ipairs(_VIEWS) do
        if view ~= other_view then
          other_view:focus()
          break
        end
      end
    end
    io.open_file(file_name)
    buffer:goto_line(tonumber(line_num))
  end
end

You can now open the ctags file, navigate to a line, and call goto_ctag() from the Lua command entry.


Edited on Monday, March 12th 2012 at 5:21 PM.