clojure-lsp / clojure-lsp

Clojure & ClojureScript Language Server (LSP) implementation

Home Page:https://clojure-lsp.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "Replace full qualified ns with alias" feature

mrkam2 opened this issue · comments

An idea of an LSP/Calva editor action: when full namespace name is used in the code, introduce an alias and use it for all such places (or use an existing one). Example:
(ns a
(:require [clojure.walk])

(clojure.walk/walk identity identity {:a 1})
(clojure.walk/walk identity identity {:b 2})
have an action to convert this to:
(ns a
(:require [clojure.walk :as walk]))

(walk/walk identity identity {:a 1})
(walk/walk identity identity {:b 2})
cc @PEZ

Could also work if original code had (:require [clojure.walk :as walk]).

Slack discussion: https://clojurians.slack.com/archives/CPABC1H61/p1710203639508699.