From b95e19e35db85f58efa0b3507833e4fd00cbf812 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 20 Feb 2019 10:32:17 -0800 Subject: [PATCH 1/2] add support for puppet notation currently puppet ctags generated via: --langdef=Puppet --langmap=Puppet:.pp --regex-Puppet=/^class[ \t]*([:a-zA-Z0-9_\-]+)[ \t]*/\1/c,class/ --regex-Puppet=/^node[ \t]*([a-zA-Z0-9_"'\.\-]+)[ \t]*/\1/n,node/ --regex-Puppet=/^site[ \t]*([a-zA-Z0-9_"'\.\-]+)[ \t]*/\1/s,site/ --regex-Puppet=/^define[ \t]*([:a-zA-Z0-9_\-]+)[ \t]*/\1/d,definition/ --regex-Puppet=/^ *([a-zA-Z:_]+) *\{ *(.*) *:/\1[\2]/r,resource/ --regex-Puppet=/^ *(@[a-zA-Z:_]+) *\{ *(.*) *:/\1[\2]/v,virtual_resource/ --regex-Puppet=/^ *([A-Z][a-zA-Z0-9_:]+) *\{/\1/f,default/ now if one highlights symbol: 'user::foo` the best this module would do is pick up 'user' module and not the 'user::foo' module. This fix is supposed to fix that. not tested --- lib/tag-reader.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tag-reader.js b/lib/tag-reader.js index 07ed8ab..6233e90 100644 --- a/lib/tag-reader.js +++ b/lib/tag-reader.js @@ -34,6 +34,7 @@ export default { const cursorPosition = cursor.getBufferPosition(); const scope = cursor.getScopeDescriptor(); const rubyScopes = scope.getScopesArray().filter(s => /^source\.ruby($|\.)/.test(s)); + const puppetScopes = scope.getScopesArray().filter(s => /^source\.puppet($|\.)/.test(s)); const wordRegExp = rubyScopes.length ? (nonWordCharacters = atom.config.get('editor.nonWordCharacters', {scope}), @@ -59,12 +60,20 @@ export default { editor.scanInBufferRange(wordRegExp, cursor.getCurrentLineBufferRange(), ({range, match}) => { if (range.containsPoint(cursorPosition)) { symbol = match[0]; - if (rubyScopes.length && symbol.indexOf(':') > -1) { + if (rubyScopes.length && symbol.indexOf(':') > -1) {0 const cursorWithinSymbol = cursorPosition.column - range.start.column; // Add fully-qualified ruby constant up until the cursor position addSymbol(wordAtCursor(symbol, cursorWithinSymbol, ':', true)); // Additionally, also look up the bare word under cursor addSymbol(wordAtCursor(symbol, cursorWithinSymbol, ':')); + } else if (puppetScopes.length && symbol.indexOf('::') > -1) {0 + const cursorWithinSymbol = cursorPosition.column - range.start.column; + // Add fully-qualified ruby constant up until the cursor position + addSymbol(wordAtCursor(symbol, cursorWithinSymbol, '::', true)); + // Additionally, also look up the bare word under cursor + addSymbol(wordAtCursor(symbol, cursorWithinSymbol, '::')); + + } else { addSymbol(symbol); } From 44ef1eabe99d5198f0c688971d6509b439a304c9 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 20 Feb 2019 10:34:26 -0800 Subject: [PATCH 2/2] remove extra characters --- lib/tag-reader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tag-reader.js b/lib/tag-reader.js index 6233e90..f88e4ad 100644 --- a/lib/tag-reader.js +++ b/lib/tag-reader.js @@ -60,13 +60,13 @@ export default { editor.scanInBufferRange(wordRegExp, cursor.getCurrentLineBufferRange(), ({range, match}) => { if (range.containsPoint(cursorPosition)) { symbol = match[0]; - if (rubyScopes.length && symbol.indexOf(':') > -1) {0 + if (rubyScopes.length && symbol.indexOf(':') > -1) { const cursorWithinSymbol = cursorPosition.column - range.start.column; // Add fully-qualified ruby constant up until the cursor position addSymbol(wordAtCursor(symbol, cursorWithinSymbol, ':', true)); // Additionally, also look up the bare word under cursor addSymbol(wordAtCursor(symbol, cursorWithinSymbol, ':')); - } else if (puppetScopes.length && symbol.indexOf('::') > -1) {0 + } else if (puppetScopes.length && symbol.indexOf('::') > -1) { const cursorWithinSymbol = cursorPosition.column - range.start.column; // Add fully-qualified ruby constant up until the cursor position addSymbol(wordAtCursor(symbol, cursorWithinSymbol, '::', true));