@@ -144,8 +144,9 @@ public List<String> getArgv() {
144144 }
145145
146146 private void initialize () {
147- command = new ArrayList <> ();
147+ env . validateUniversalCtags ();
148148
149+ command = new ArrayList <>();
149150 command .add (env .getCtags ());
150151 command .add ("--c-kinds=+l" );
151152
@@ -250,7 +251,9 @@ private void run() throws IOException {
250251 }
251252
252253 private void addRustSupport (List <String > command ) {
253- command .add ("--langdef=rust" );
254+ if (!env .getCtagsLanguages ().contains ("Rust" )) { // Built-in would be capitalized.
255+ command .add ("--langdef=rust" ); // Lower-case if user-defined.
256+ }
254257 defaultLangMap .add (".RS" , "rust" ); // Upper-case file spec
255258
256259 // The following are not supported yet in Universal Ctags b13cb551
@@ -264,9 +267,12 @@ private void addRustSupport(List<String> command) {
264267 }
265268
266269 private void addPowerShellSupport (List <String > command ) {
267- command .add ("--langdef=powershell" );
270+ if (!env .getCtagsLanguages ().contains ("PowerShell" )) { // Built-in would be capitalized.
271+ command .add ("--langdef=powershell" ); // Lower-case if user-defined.
272+ }
268273 defaultLangMap .add (".PS1" , "powershell" ); // Upper-case file spec
269274 defaultLangMap .add (".PSM1" , "powershell" ); // Upper-case file spec
275+
270276 command .add ("--regex-powershell=/\\ $(\\ {[^}]+\\ })/\\ 1/v,variable/" );
271277 command .add ("--regex-powershell=/\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1/v,variable/" );
272278 command .add ("--regex-powershell=/^[[:space:]]*(:[^[:space:]]+)/\\ 1/l,label/" );
@@ -283,8 +289,11 @@ private void addPowerShellSupport(List<String> command) {
283289 }
284290
285291 private void addPascalSupport (List <String > command ) {
286- command .add ("--langdef=pascal" );
292+ if (!env .getCtagsLanguages ().contains ("Pascal" )) { // Built-in would be capitalized.
293+ command .add ("--langdef=pascal" ); // Lower-case if user-defined.
294+ }
287295 defaultLangMap .add (".PAS" , "pascal" ); // Upper-case file spec
296+
288297 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*\\ ([[:space:]]*[[:alnum:]_][[:space:]]*\\ )/\\ 1/t,Type/" );
289298 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*class[[:space:]]*[^;]*$/\\ 1/c,Class/" );
290299 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*interface[[:space:]]*[^;]*$/\\ 1/i,interface/" );
@@ -298,7 +307,9 @@ private void addPascalSupport(List<String> command) {
298307 }
299308
300309 private void addSwiftSupport (List <String > command ) {
301- command .add ("--langdef=swift" );
310+ if (!env .getCtagsLanguages ().contains ("Swift" )) { // Built-in would be capitalized.
311+ command .add ("--langdef=swift" ); // Lower-case if user-defined.
312+ }
302313 defaultLangMap .add (".SWIFT" , "swift" ); // Upper-case file spec
303314 command .add ("--regex-swift=/enum[[:space:]]+([^\\ {\\ }]+).*$/\\ 1/n,enum,enums/" );
304315 command .add ("--regex-swift=/typealias[[:space:]]+([^:=]+).*$/\\ 1/t,typealias,typealiases/" );
@@ -311,9 +322,12 @@ private void addSwiftSupport(List<String> command) {
311322 }
312323
313324 private void addKotlinSupport (List <String > command ) {
314- command .add ("--langdef=kotlin" );
325+ if (!env .getCtagsLanguages ().contains ("Kotlin" )) { // Built-in would be capitalized.
326+ command .add ("--langdef=kotlin" ); // Lower-case if user-defined.
327+ }
315328 defaultLangMap .add (".KT" , "kotlin" ); // Upper-case file spec
316329 defaultLangMap .add (".KTS" , "kotlin" ); // Upper-case file spec
330+
317331 command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
318332 "(private[^ ]*|protected)?[[:space:]]*class[[:space:]]+([[:alnum:]_:]+)/\\ 4/c,classes/" );
319333 command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
@@ -334,8 +348,13 @@ private void addKotlinSupport(List<String> command) {
334348 command .add ("--regex-kotlin=/^[[:space:]]*import[[:space:]]+([[:alnum:]_.:]+)/\\ 1/I,imports/" );
335349 }
336350
351+ /**
352+ * Override Clojure support with patterns from https://gist.github.com/kul/8704283.
353+ */
337354 private void addClojureSupport (List <String > command ) {
338- command .add ("--langdef=clojure" ); // clojure support (patterns are from https://gist.github.com/kul/8704283)
355+ if (!env .getCtagsLanguages ().contains ("Clojure" )) { // Built-in would be capitalized.
356+ command .add ("--langdef=clojure" ); // Lower-case if user-defined.
357+ }
339358 defaultLangMap .add (".CLJ" , "clojure" ); // Upper-case file spec
340359 defaultLangMap .add (".CLJS" , "clojure" ); // Upper-case file spec
341360 defaultLangMap .add (".CLJX" , "clojure" ); // Upper-case file spec
@@ -353,9 +372,12 @@ private void addClojureSupport(List<String> command) {
353372 }
354373
355374 private void addHaskellSupport (List <String > command ) {
356- command .add ("--langdef=haskell" ); // below was added with #912
375+ if (!env .getCtagsLanguages ().contains ("Haskell" )) { // Built-in would be capitalized.
376+ command .add ("--langdef=haskell" ); // below added with #912. Lowercase if user-defined.
377+ }
357378 defaultLangMap .add (".HS" , "haskell" ); // Upper-case file spec
358379 defaultLangMap .add (".HSC" , "haskell" ); // Upper-case file spec
380+
359381 command .add ("--regex-haskell=/^[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/c,classes/" );
360382 command .add ("--regex-haskell=/^[[:space:]]*data[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
361383 command .add ("--regex-haskell=/^[[:space:]]*newtype[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
@@ -367,8 +389,11 @@ private void addHaskellSupport(List<String> command) {
367389 }
368390
369391 private void addScalaSupport (List <String > command ) {
370- command .add ("--langdef=scala" ); // below is bug 61 to get full scala support
392+ if (!env .getCtagsLanguages ().contains ("Scala" )) { // Built-in would be capitalized.
393+ command .add ("--langdef=scala" ); // below is bug 61 to get full scala support. Lower-case
394+ }
371395 defaultLangMap .add (".SCALA" , "scala" ); // Upper-case file spec
396+
372397 command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
373398 "(private|protected)?[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 4/c,classes/" );
374399 command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
0 commit comments