Community
    • Login

    I want (to make) a JS IntelliSense Plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    javascriptauto-completeautocompleteauto-completionautocompletion
    28 Posts 5 Posters 4.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael VincentM
      Michael Vincent
      last edited by

      @PeterJones said in I want (to make) a JS IntelliSense Plugin:

      The TagLEET might enable that… Again, @Michael-Vincent is our most-active user that I know uses ctags with Notepad++

      @Sashank999

      Yes, my modified fork of TagLEET does autocompletion based on the tags file. I actually asked about this in a form post a while back and since I was already modifying TagLEET to do other stuff and realized the tags file would have function names, I added the autocompletion feature.

      With my modified TagLEET, it can generate the tags file for your file and / or project (project more applicable in this case) and it auto-updates that tags file every time you save - so newly coded functions and tags are added automatically. Then when you’re coding away and need to autocomplete, you have some options. I have Notepad++ “native” autocomplete enabled:

      0a38adf2-2a96-4d59-8f11-55fbafd33f92-image.png

      The TagLEET “Scintilla autocomplete”:

      b8bcf056-33bc-4176-a2d2-40450d259c8e-image.png

      works “seamlessly” with the Notepad++ “native” by just populating the autocomplete list with tags from the tags file that match. Note it does not merge the list with Notepad++ autocomplete list from the settings above - no way to do that as far as I know. But I do add an icon to help you see that it’s a TagLEET autocomplete. Below, regular Notepad++:

      74378962-422b-4868-b3ee-3c7e5c9aea95-image.png

      Typing something that does not exist in my current file, but is in another file from my project and thus in my tags file:

      057fc5a1-b13c-40f3-bf7f-d6006468eb99-image.png

      Notice the little boxes icon - that’s TagLEET offerings from the tags file.

      If that isn’t getting you want you want, there is also a menu item “Plugins => TagLEET => Autocomplete” which forces a TagLEET window to pop-up with all possible autocompletions from the tags file:

      a4ca8086-7186-4375-9d14-aebd251eabfa-image.png

      I like the automatic Notepad++ / Scintilla autocomplete lists, but wanted to make sure I could always get an autocomplete from a tags file if available.

      I assign shortcut keys to TagLEET. I forget if any are default set by the plugin, I’ve configured these through the menu Settings => Shortcut Mapper…:

      cbb0dd37-027a-4eb2-8cb2-f5adb8588e0e-image.png

      Note that by doing a “Lookup Tag” on a file that does not have a tags file created or one can’t be found will create a prompt for you to create the tags file, so on your first tags lookup, you’ll be prompted to create the tags file (recursively, for the current file only, or cancel) and you can choose the directory to start the recursion in - so the top level directory of your project.

      I include a version of Universal cTags executable in the plugin so if you have a %USERPROFILE%\.ctags.d\config.ctags file, it will respect those configs to ctags.exe - I use that to add a bunch of additional tags to search for a create a few new language parses like for SNMP MIB ASN.1 and Cisco router configs.

      Since the “real” TagLEET is offered through Plugin Admin, my forked version is always marked as “pre-release” and can only be manually installed. Instructions on the README.

      Cheers.

      Michael VincentM Sashank999S 2 Replies Last reply Reply Quote 4
      • Michael VincentM
        Michael Vincent @Michael Vincent
        last edited by

        @Michael-Vincent said in I want (to make) a JS IntelliSense Plugin:

        Yes, my modified fork of TagLEET does autocompletion based on the tags file.

        @Sashank999

        Before you go down a single path, you may also take a look at NppGTags, which is in Plugin Admin, does the same (more or less) with cTags but also has autocompletion and reference lookup (in some cases) baked in to the mainline version of the plugin.

        Try them both out and see which interface and workflow works better for you. I also believe autocomplete can be done with the jN plugin through JavaScript - you seem to be familiar / comfortable with that.

        Cheers.

        1 Reply Last reply Reply Quote 2
        • TroshinDVT
          TroshinDV
          last edited by

          У меня есть скрипт, который JS IntelliSense реализует.
          Screenshot_47.png
          https://github.com/trdm/jn-npp-scripts
          скрипт: https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js

          1 Reply Last reply Reply Quote 3
          • Sashank999S
            Sashank999 @Michael Vincent
            last edited by

            @Michael-Vincent Dude that is really awesome and perfectly fits for my needs
            I found the original TagLEET and used it but it doesn’t work for me.
            I used your fork and it worked great. I also setup a global tags file in my scripts directory and set it in TagLEET.
            Now there are only 2 problems for me:

            • ctags also includes CSS files for tags (but I solved that by adding an --exclude option)
            • ctags also indexes the same name(or tag) multiple times in multiple files
              This is intended to show the locations of all matching tags but this results like Imgur
              I don’t need such thing. It also made the file quite big(227KB). I only need auto completion. But I didn’t find any option to remove multiple tags. If there is such thing, could you please say me ?
            Michael VincentM 1 Reply Last reply Reply Quote 0
            • Sashank999S
              Sashank999
              last edited by

              I also forgot to say another thing.
              This kind of auto complete is really useful in JS but it sucks in CSS.
              How do I enable TagLEET auto complete for only JS files and disable TagLEET but enable Npp default auto complete in all other files ?
              Thanks for the modified TagLEET bro :)

              Michael VincentM 1 Reply Last reply Reply Quote 0
              • Michael VincentM
                Michael Vincent @Sashank999
                last edited by

                @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                ctags also indexes the same name(or tag) multiple times in multiple files

                I don’t know if there is a way to control filtering the same tag found in multiple files / locations in cTags, I think it’s by design like you said, “This is intended to show the locations of all matching tags”. I agree that it makes the autocomplete list redundant in some cases.

                In my TagLEET, the Scintilla autocomplete happens here:
                https://github.com/vinsworldcom/nppTagLEET/blob/17ea5e6e2dc0fe67d69600b8a63cff3109dc9b14/tag_leet_app.cpp#L871

                I could try to create a hash of the tags seen and if the Item->Next is in the seen hash, just continue;. I’m not a C++ expert especially with strings, so creating a hash of seen strings is a bit of a homework assignment I can’t do right now, but certainly something to look at for the next (pre)release.

                Cheers.

                1 Reply Last reply Reply Quote 0
                • Michael VincentM
                  Michael Vincent @Sashank999
                  last edited by

                  @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                  How do I enable TagLEET auto complete for only JS files and disable TagLEET but enable Npp default auto complete in all other files ?

                  Currently no option for that. So long as a tags file exists in the working path, it will use it unless you disable Scintilla autocomplete from the TagLEET Settings menu, which disables it across all files.

                  Did you give jN a try - as seen in the above post? It seems more geared towards Javascript which may more directly address your specific use case.

                  Cheers.

                  1 Reply Last reply Reply Quote 1
                  • TroshinDVT
                    TroshinDV @Sashank999
                    last edited by

                    @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                    Heya!
                    I am a JS Dev. I develop on a lot of small individual files and have the habit of separating all functions into their own files. And I need the function names in all the JS files I edit. How can this be done ?

                    Это реализовано в https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js
                    function goToDefinitionsByCtagsGlobal()
                    Собирает и выдает все функции и классы текущей дирректории файла.
                    Используется ctags + сервер выбора https://github.com/trdm/jn-npp-scripts/blob/master/system/svcsvc.dll

                    Alan KilbornA TroshinDVT 2 Replies Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @TroshinDV
                      last edited by

                      @TroshinDV

                      Isn’t this an English forum?

                      TroshinDVT 1 Reply Last reply Reply Quote 0
                      • TroshinDVT
                        TroshinDV @Alan Kilborn
                        last edited by TroshinDV

                        @Alan-Kilborn I know English badly, If I try to write in English, it will be terrible

                        1 Reply Last reply Reply Quote 0
                        • TroshinDVT
                          TroshinDV @TroshinDV
                          last edited by

                          @TroshinDV said in I want (to make) a JS IntelliSense Plugin:

                          Это реализовано в https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js

                          Although it is necessary to remake as it should, it was written in a hurry.

                          Alan KilbornA Sashank999S 2 Replies Last reply Reply Quote 1
                          • Alan KilbornA
                            Alan Kilborn @TroshinDV
                            last edited by

                            @TroshinDV

                            I think when you want to use an English forum and you do not write it well, it is on you to use a translator before posting, and to feed any English responses through a translator so that you can read them.

                            And it appears you have done that in your most recent post, for which everyone thanks you, I’m sure.

                            1 Reply Last reply Reply Quote 1
                            • Sashank999S
                              Sashank999 @TroshinDV
                              last edited by

                              @TroshinDV I absolutely don’t understand what you are saying.
                              I have no understanding of Russian Language.
                              Could you please also translate the README.md to English too so that not only me but many can find your plugin useful ?

                              PeterJonesP TroshinDVT 3 Replies Last reply Reply Quote 0
                              • PeterJonesP
                                PeterJones @Sashank999
                                last edited by

                                @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                @TroshinDV I absolutely don’t understand what you are saying.
                                I have no understanding of Russian Language.
                                Could you please also translate the README.md to English too so that not only me but many can find your plugin useful ?

                                It’s one thing to ask someone to somehow translate into English in an English-language forum. (And as @Alan-Kilborn suggested, I think if @TroshinDV isn’t comfortable composing posts and replies in English, using a translator like translate.google.com or deepl.com, paste in the Russian that @TroshinDV writes in and grab the English translation to post into the forum is a good idea.)

                                But as the developer of the plugin, it is perfectly reasonable for @TroshinDV to choose to write and pubish the README in whatetver language is most comfortable, without being required to translate for others. And since it’s easy to translate someone’s published webpage (if you are in Chrome, right-click and “Translate to English”; if you are on a different browser without google’s builtin translation, you can pass the URL to translate.google.com, like http://translate.google.com/translate?sl=auto&tl=en&u=https://github.com/trdm/jn-npp-scripts/blob/master/readme.md, and see the English translation), and since @TroshinDV has already indicated not being comfortable translating into English, I think it’s probably faster all around for you to use the auto-translation.

                                1 Reply Last reply Reply Quote 3
                                • TroshinDVT
                                  TroshinDV @Sashank999
                                  last edited by TroshinDV

                                  @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                  Could you please also translate the README.md to English too so that not only me but many can find your plugin useful ?

                                  Maybe it’s good that there is no translation, will not be ashamed of the software code in front of English programmers :)))))

                                  1 Reply Last reply Reply Quote 1
                                  • Sashank999S
                                    Sashank999
                                    last edited by

                                    Heya !

                                    I need a small help.
                                    I now have an F5 action that automatically generates a ctags database with only keywords. Nothing other than that.
                                    So now, TagLEET refuses to work without the other things like path, keyword scope, etc.
                                    Of course it would be great if TagLEET disables other features and enables auto completion only as it doesn’t have info for the other features. I feel a bit too greedy now :| .

                                    As I can generate a database, I want to make a plugin that can read the database and provide autocompletion based on that.
                                    So, the things I need in plugin:

                                    • an on/off switch to enable/disable auto completion
                                    • an input field with “Browse” option beside it that can select a keywords file

                                    Can anyone please provide info of how I can do it ? I think C will be enough. I just need the documentation to plugin development.

                                    TroshinDVT PeterJonesP 5 Replies Last reply Reply Quote 0
                                    • TroshinDVT
                                      TroshinDV @Sashank999
                                      last edited by TroshinDV

                                      @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                      As I can generate a database, I want to make a plugin that can read the database and provide autocompletion based on that.

                                      https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js

                                      /* 
                                      \todo.... 2018-3-07_19-25
                                      	может не страдать херней, а для проектов на си и си++ использовать рекурсивные запуски типа:
                                      	ctags.exe -R -f u_ctagsU.txt --language=c --excmd=number
                                      	???? гораздо быстрее получается и гораздо точнее, что немаловажно..
                                      	
                                      // trdm 2019-02-14 08:05:07    
                                      \todo - при сканировании директории C:\Progekts\_E\ReactOS 
                                      	файл trdm.txt вырос до 80 мб. этот объем не осилить js.
                                      	тут надо придумать что-то другое.
                                      */
                                      //Парсим с помощью ctagsU.exe файл
                                      function fileToCtags( psFileName, psFirst, psFIndex ) {
                                      	var vFName = psFileName;
                                      	if(!vFName) {
                                      		return;
                                      	}
                                      	if(!psFIndex) {		psFIndex = 1;    }
                                      	var vComandLine = '';
                                      	var vComandLineM = ' --machinable=yes ';
                                      	var ctagExePath = gIntelCTagsUExeFPath;
                                      	if(IntellPlus.curExtension == '1s' || IntellPlus.curExtension == 'vbs' ) {
                                      		ctagExePath = gIntelCTagsUExeFPathSpeshl; 
                                      		vComandLineM = '';		// no '--machinable=yes'
                                          }
                                          var resFile = (psFIndex == 1) ? gIntelCTagsUFPath : gIntelCTagsUFPath2;
                                          resFile = gIntelCTagsUFPath; // Не помню зачем я сдел 2 файла,  пока оставим один.
                                      	var isFolder = gFso.FolderExists(psFileName);
                                      	if(!isFolder) {
                                      		var vFirst = (psFirst) ? true : false;
                                      		var vFChar = (vFirst) ? '' : ' -a ';
                                      		if(!gFso.FileExists(vFName)) return;
                                      		if(!gFso.FileExists(ctagExePath)) return; 	// --if0=yes --list-fields - не обрабатывается
                                      		vComandLine = '"'+ctagExePath+'"'+vFChar+' -R -F '+vComandLineM+' --sort=no --excmd=number -f "'+resFile+'" "'+vFName+'"';	// debugger;
                                      		if(psFIndex == 2) {
                                      			vComandLine = '"'+ctagExePath+'"'+vFChar+' -R -F --sort=no --excmd=number -f "'+resFile+'" "'+vFName+'"';	// debugger;
                                              }
                                          } else {
                                      		vComandLine = '"'+ctagExePath+'" -R -F '+vComandLineM+' --sort=no --excmd=number -f "'+resFile+'" "'+vFName+'"';	// debugger;
                                      	}
                                      	if(!gIntelShowParseLine) { 
                                      		status('Parse: '+vFName);	// var gWshShell = new ActiveXObject("WScript.Shell");
                                      	}
                                      	status('WshShell.Run: '+vComandLine);	// var gWshShell = new ActiveXObject("WScript.Shell");
                                      	if(gIntelShowParseLine) {
                                      		//message(vComandLine);    
                                          }
                                      	//writeToIntellLog('gWshShell.Run: '+vComandLine);
                                      	
                                      	gWshShell.Run(vComandLine,0,true);
                                      	//gWshShell.Exec()
                                      	return gFso.FileExists(resFile);
                                      }
                                      
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • TroshinDVT
                                        TroshinDV @Sashank999
                                        last edited by TroshinDV

                                        @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                        So, the things I need in plugin:

                                        • an on/off switch to enable/disable auto completion

                                        https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js

                                        function switchIntellMode(){
                                        	gIntellEnabled = !gIntellEnabled;
                                        	gIntellModeMenuItem.checked = gIntellEnabled;	
                                        }
                                        
                                        var mySwitchIntellMode = {
                                            text: "Intellisense (вкл/выкл)\tctrl+F8", //"Switch intell mode\tctrl+F8", 
                                            ctrl: true,
                                            shift: false,
                                            alt: false,
                                            key: 0x77,
                                            cmd: switchIntellMode,
                                        	prompt: "Функция switchIntellMode"
                                        };
                                        
                                        addHotKey(mySwitchIntellMode); 
                                        gIntellModeMenuItem = scriptsMenu.addItem(mySwitchIntellMode);
                                        gIntellModeMenuItem.checked = gIntellEnabled;
                                        
                                        

                                        сам запуск: getWordList()

                                        
                                        GlobalListener.addListener({
                                        	CHARADDED:function(v, pos){		// Tab не счистается символом? Не срабатывает функция..
                                        		if (gIntellEnabled){			//debugger;
                                        			gCurentCharAdded = v;
                                        			var curWord = getWordList();				 
                                        		}		
                                        	}
                                        });
                                        
                                        

                                        а потом смотри работу функции getWordList()

                                        1 Reply Last reply Reply Quote 0
                                        • TroshinDVT
                                          TroshinDV @Sashank999
                                          last edited by TroshinDV

                                          @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                          So, the things I need in plugin:

                                          • an input field with “Browse” option beside it that can select a keywords file

                                          https://github.com/trdm/jn-npp-scripts/blob/master/includes/Intell.js

                                          /*	UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
                                          	Основная процедура запуска скрипта. Обеспечивает распознавание возможности коде-комплита, 
                                          	парсинг, выбор вваринта и встравку результата во view. -_- */
                                          function getWordList() {
                                           	if(gIntellDebug) {
                                          		debugger;
                                          	}	
                                          	gSearchCount = 0;
                                          	var retVal = '';
                                          	var curWord = IntellPlus.getCurWord(); 	<<<<<<< see that fore you task "an input field with “Browse” option beside it that can select a keywords file"
                                          	if (!curWord) { 
                                          		if(IntellPlus.isHtml()) {
                                          			HtmlIntell(); 
                                          			// \\todo - тормоза, надо отдебажить, но автоподстановка в <img src="img/Screenshot_001.png" alt=""> работает хорошо.
                                                  }
                                                  /*insertTemplate();*/
                                                  if (IntellPlus.cursorInComment) {
                                                      CommentIntell();
                                                  }
                                          		return; 
                                          	}
                                          
                                          

                                          текущее слово берется прямо из редактора.

                                          1 Reply Last reply Reply Quote 0
                                          • TroshinDVT
                                            TroshinDV @Sashank999
                                            last edited by

                                            @Sashank999 said in I want (to make) a JS IntelliSense Plugin:

                                            Can anyone please provide info of how I can do it ? I think C will be enough. I just need the documentation to plugin development.

                                            ты же собирался на JS писать. Я практически все за тебя сделал, тебе только изучить надо.
                                            You were going to write on JS. I practically did everything for you, you only need to explore it.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors