         (progn
           (setq ectags--file-name local-tags-filename)
           t)
-      ;; (progn (message "Valid tags table")
-      ;;        (setq ectags--obarray (make-ectags-obarray)))
       (error "Not a valid tags table")
       nil)))
 

  (set-syntax-table text-mode-syntax-table)
  (use-local-map ectags-mode-map)

  (unless ectags-big-file-command-format
    (unless (executable-find "rg")
      (if (executable-find "grep")
          (setq ectags-big-file-command-format "grep \"^%s\\b\" %s")
        (message "Warning: rg or grep not installed. Will be slow for big files")
        (setq ectags-big-file-command-format nil))))

  (setq-local show-trailing-whitespace nil)
  (setq-local overlay-arrow-position nil)

another completion system for narrowing down by substring."
  (interactive)
  (ectags-find (completing-read "Tag to find: " ectags--obarray)))

(defun counsel-ectags-function (input)
  (if (not ectags--file-name)
      (ectags-visit-tags-table "tags"))

  (if (< (length input) 3)
      (counsel-more-chars 3)
    (counsel--async-command
     (format "rg -N %s %s" input ectags--file-name))
    '("" "working...")))

(defun counsel-ectags-action (tag-line)
  (ectags-match tag-line)

  (when ectags--matches
    (with-ivy-window
      (xref-push-marker-stack)

      (find-file (file-relative-name (ectags-match-filename (car ectags--matches))))
      (goto-char (point-min))
      (forward-line (1- (ectags-match-linenumber (car ectags--matches))))
      (recenter-top-bottom)
      (unless (eq ivy-exit 'done)
        (swiper--cleanup)
        (swiper--add-overlays (ivy--regex ivy-text))))))

;;;###autoload
(defun counsel-ectags (&optional initial-input)
  (interactive)
  (ectags-visit-tags-table "tags")
  (ivy-read "Find tag: "
            #'counsel-ectags-function
            :initial-input (concat "^" initial-input)
            :dynamic-collection t
            :action #'counsel-ectags-action
            :unwind (lambda ()
                      (counsel-delete-process)
                      (swiper--cleanup))
            :caller 'counsel-ectags))

;;;###autoload
(defun ectags-find-tag ()
