 
   (add-hook! nlinum-mode
     (setq nlinum--width
-          (length (int-to-string (count-lines (point-min) (point-max)))))))
+          (length (save-excursion (goto-char (point-max))
+                                  (format-mode-line "%l"))))))
 
 
 ;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;

            (when (>= peol max)
              (setq peol max)))
          (jit-lock-fontify-now pbol peol)
          (let* ((overlays (overlays-in pbol peol))
                 (ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays)))
            (when ov
              (narf|nlinum-unhl-line)
              (let ((str (nth 1 (get-text-property 0 'display (overlay-get ov 'before-string)))))

  (defun narf|nlinum-unhl-line ()
    "Unhighlight line number"
    (when narf--hl-nlinum-overlay
      (let* ((disp (get-text-property
                    0 'display (overlay-get narf--hl-nlinum-overlay 'before-string)))
             (str (nth 1 disp)))
        (put-text-property 0 (length str) 'face 'linum str)
        (setq narf--hl-nlinum-overlay nil
              narf--hl-nlinum-line nil)
        disp)))

  (defun narf|nlinum-hl-line (&optional line)
    "Highlight line number"
    (let ((line-no (or line (string-to-number (format-mode-line "%l")))))
      (when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
        (let* ((pbol (if line
                         (save-excursion (goto-char (point-min))
                                         (forward-line line-no)
                                         (line-beginning-position))
                       (line-beginning-position)))
               (peol (1+ pbol)))
          ;; Handle EOF case
