Code Monkey home page Code Monkey logo

nppgtags's Introduction

To support NppGTags consider donating. Thank You. Donate

--- NppGTags ---

GTags plugin for Notepad++

This is a front-end to GNU Global source code tagging system (GTags) for Notepad++. It provides various functions to ease project code navigation - search for file, definition, reference, literal, regular expression, perform auto-completion.

You'll need GTags binaries for Win32 to use this plugin. Those are supplied with the plugin binary for convenience. You can also download them from GNU Global official website - look for the Win32 port. Put GTags Win32 binaries in folder named bin.

Build Status

AppVeyor Build status

Installation

For Notepad++ versions 7.6.3 and above you can use the built-in PluginAdmin dialog (accessible through the Plugins menu).

You can manually install the plugin by copying NppGTags.dll, bin folder (containing GTags binaries) and share folder (containing pygments parser .py script) to your Notepad++ plugins directory. After Notepad++ version 7.6, the above files should be copied in Notepad++ plugins directory BUT in a separate sub-folder named NppGTags. Restart Notepad++ and you are all set.

Usage

You can find all supported commands in the NppGTags plugin menu. To make your life easier use Notepad++'s shortcut settings to assign whatever shortcuts you like to the plugin commands. There are no predefined shortcuts in the plugin to avoid possible conflicts with other Notepad++ plugins.

Use plugin Settings to tune its operation. There you can select the code parser to be used. The default is the built-in GTags parser but it supports only C, C++, Java, PHP and several other languages at the time this doc was written. Ctags supports considerably more languages and is continuously evolving but does not allow reference search at the moment. Pygments also supports lots of languages + reference search but requires external Python library (Pygments) that is not supplied with the plugin.

From Settings you can also set the auto-update database behavior, the linked libraries databases (if any) and the ignored sub-paths. The linked libraries are completely manageable from the settings window. The ignored sub-paths setting is used for results filtering - the configured database sub-paths will be excluded from the search results.

There are two copies of the above-mentioned settings that are identical:

  1. The global (default) ones: Those are used whenever the project / library database is created for the first time. You can access those at any time - just open the Settings window.
  2. Per database settings: Those are related to the specific database. You can access those when you open Settings window while you are editing a project file.

You can also set a default database that will be used when performing searches from files without their own database (unparsed files). This setting is only global.

To start using the plugin first you need to create GTags database for your project - Create Database. In the dialog simply select your project's top folder and GTags will index recursively all supported by the chosen parser source files. It will create database files (GTAGS, GRTAGS, GPATH and NppGTags.cfg) in the selected folder.

Delete Database invoked from any opened file in the project will delete those.

If you run one of the plugin's Find commands (those include the Search commands) from any opened file in the project it will search the database for:

  1. what you have selected if there is selection;
  2. the word that is under the caret if there is no selection;
  3. what you have entered in the search box that will appear if there is no word under the caret.

The search box allows choosing case sensitivity and regexp for the Find command where applicable. It also provides search completion list where possible which appears when you enter several characters in the box. If the Find command is started without the search box (case 1 and 2) the search is literal (no regexp) and the case sensitivity depends on the menu flag Ignore Case.

Find File command will skip step 2, it will directly go to step 3 if there is no selection. It will automatically fill the search box (from step 3) with the name of the current file without the extension to make switching between source <-> header file easier. Find File will search for paths containing the given string (anywhere in the name) although its search completion will show only paths that start with the entered string. That means that even if there is no completion shown you can still perform the search and find files containing the entered string. All paths are relative to the project's directory.

In GTags' terminology, Symbol is reference to identifier for which definition was not found. All local variables are symbols for example. If you search for Definition / Reference and GTags doesn't find anything the plugin will automatically invoke search for Symbol. This will be reported in the search results window header.

Any Search will search for a string either "literally" (not using regular expressions) or using regular expressions if that is selected through the search box options. Search in Source Files will look only in files that are recognized as sources by the parser during database creation. Search in Other Files respectively will look in all other (non-binary) files. This is useful to dig into documentation (text files) or Makefiles for example.

As a summary, Find Definition / Reference will search for identifiers (single whole words) whereas Search... will search for strings in general (parts of words, several consecutive words, etc.) either literally or using regular expressions.

AutoComplete will show found Definitions + found Symbols. It will look for the string from the beginning of the word to the caret position. Autocomplete case sensitivity also depends on the menu flag Ignore Case.

While auto complete results window is active you can narrow the results shown by continuing typing. Backspace will undo the narrowing one step at a time (as the newly typed characters are deleted). Double-clicking or pressing Enter, Tab or Space will insert the selected auto complete result.

AutoComplete Filename is useful if you will be including headers for example.

AutoComplete and Find Definition commands will also search library databases if such are used. That is configured per database through the plugin's Settings window.

All Find commands will show Notepad++ docking window with the results. Each such command will place its results in a separate tab that will automatically become active. Clicking on another tab will show that command's results. You can also use the ALT + Left and ALT + Right arrow keys to switch between tabs.

Double-clicking, hitting Space or Enter on search result line will take you to the source location. You can also do that by left-clicking on the highlighted searched word in the result line. Your currently edited document location will be saved - use Go Back command to visit it again. You can 'undo' the Go Back action by using Go Forward command. By using the mouse or the arrow keys you can move around result lines and you can trigger new searches directly from the results window (same rules about the searched string apply).

Right clicking or hitting ESC will close the currently active search results tab.

Left-clicking in the margin area ([+] / [-] signs) or pressing '+' / '-' keys will unfold / fold lines. To fold a line it is not necessary to click exactly the [-] sign in the margin - clicking in any sub-line's margin will do. Pressing ALT + '+' / '-' keys will unfold / fold all lines. You can accomplish that also by double-clicking or hitting Space or Enter on the search results head line - this will toggle all lines fold / unfold state. Clicking in head line margin or pressing '+' / '-' keys while head line is the active one will do the same.

The results window is Scintilla window actually (same as Notepad++). This means that you can use CTRL + mouse scroll to zoom in / out or you can select text and copy it (CTRL + 'C').

When the focus is on the results window pressing CTRL + 'F' will open a search dialog. Fill-in what you are looking for and press Enter. The search dialog will remain open until you press ESC. While it is open you can continue searching by pressing Enter again. Shift + Enter searches backwards. If you close the search dialog you can continue searching for the same thing using F3 and Shift + F3 (forward or backward respectively). F3 works while the search dialog is open as well. The search always wraps around when it reaches the results end - the Notepad++ window will blink to notify you in that case.

When the focus is on the results window pressing F5 will re-run the same search as the active results tab. This is kind-of active results tab refresh.

Toggle Results Window Focus command is added for convenience. It switches the focus back and forth between the edited document and the results window. It's meant to be used with a shortcut so you can use the plugin through the keyboard entirely.

Enjoy!

nppgtags's People

Contributors

chcg avatar pnedev avatar zapati avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nppgtags's Issues

Add panel with tags dynamically generated for active file

It would be convenient to have a dockable panel with a list of tags (at least for the active single file). The content of this panel can be generated dynamically as we switch to different files. Such a dynamic file tags can be kept/update in the plugin/config directory (or in configure location). This would provide quick support for any language which are covered by used generator (like Universal Ctags).

Something like this would be better than the built-in Function List, which is much weaker than the built-in parsers in usage tools by this plugin. Thanks to this for a single file we don't have to constantly call plugin commands searching for individual symbols. Such a list allows us to quickly find out (recall) the different names in a given file.

An example would be a plugin SourceCookifier, unfortunately it uses outdated Exuberant Ctags (in addition modified), and many things are no longer recognized. In its window tags can be presented in various forms as flat/flat grouped/grouped, which is very convenient. In addition it also supports working on an NPP session or own session, but it would be nice if NppGtags at least will support a single file mode (cross we can achieved using the current search mechanisms on previously generated tags for all files in project, which are sufficient).

image

Add command Go To File/Definition/Reference

Any chance add that commands? They would automatically move to the indicated place, without opening bottom find panel where we must manually select correct hint.
If we need only fast go/back between different places in our code it would be a good improvement.

Results windows auto-expand option

Add an option that enable or disable auto expansion of results windows.

For "find reference" function, the results is supposed to be short. It could be nice that the result is directly visible

Cheers

I get nothing when "Find Reference"

I use nppgtags to browser c source code. I have created gtags file in the root direction, but when I the try to "Find Refernece" of a symbol, I got nothing. Here is the screenshot.

Improve automation of database creation

Actually, this is the popup shown when the database is missing:

image

Maybe it would be cool to add a database creation option to the popup? For example:

Title : Gtags database not found. Do you want to create it?
Answers: Yes | No

This would appear everytime a user is trying to do some actions which would involve the existence of a database. Just a little idea.

setting to disable error messages

Feature request: ability to disable alert dialogs from parsing errors. The parsing isn't always perfect and with a large enough codebase there's sure to be lines that are either formatted exotically enough or use newer language syntax that they trip up the parser and result in errors like this:
Untitled
It would remove a huge annoyance to be able to suppress these messages!

I use this plugin often, thank you for maintaining.

Support for excluding certain sub paths from tag generation.

To improve tagging speed it would be nice if there was a way to exclude sub paths from tag generation instead of just search results. Not sure if this is something that can be accomplished in nppgtags or requires changes in Universal CTags

As a bit of justification, a project I work on takes about 45min to tag (and generates a ~2GB tag file) being able to exclude chunks of the source tree I don't care about would speed up tagging significantly.

Results widow closes (ncorrectly) when clinging a result if mouse buttons are swapped.

A recent addition to nppGtags posting three key-up events and one mouse-up event causes the results window to always close, incorrectly, when navigating to a search result. A significant inconvenience.

The code at issue is:

`void ResultWin::releaseKeys()
{
INPUT inputs[4] = {};
ZeroMemory(inputs, sizeof(inputs));

inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.wVk = VK_SHIFT;
inputs[0].ki.dwFlags = KEYEVENTF_KEYUP;

inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.wVk = VK_CONTROL;
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;

inputs[2].type = INPUT_KEYBOARD;
inputs[2].ki.wVk = VK_MENU;
inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;

inputs[3].type = INPUT_MOUSE;
inputs[3].mi.dwFlags = MOUSEEVENTF_LEFTUP;

SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));

}`

The issue is that the LEFTUP is always sent even when the actual button is the right button.

The fix (tested to work) is to set the correct event flag based on the button swapping state, like:

inputs[3].mi.dwFlags = GetSystemMetrics(SM_SWAPBUTTON) ? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP;

User selectable folder to store the created databases

The actual implementation of NppGTags consists in creating the database file in the project's root.

It would be nice to store the database files in a user selectable folder, not necessarily residing in the project path.

forward backward list

It would be nice to be able to see a window of of the tags stack. Like I start at a top layer of code then follow the calling sequence down 10 levels it would be nice to see that list or stack.

Double click Search Result Does not open source file

I try to double click search result windows but it does not open the source file

From the document /guide:

Double-clicking, hitting Space or Enter on search result line will take you to the source location. You can also do that by left-clicking on the highlighted searched word in the result line. Your currently edited document location will be saved - use Go Back command to visit it again. You can 'undo' the Go Back action by using Go Forward command. By using the mouse or the arrow keys you can move around result lines and you can trigger new searches directly from the results window (same rules about the searched string apply).

Right clicking or hitting ESC will close the currently active search results tab.

When i do "Find definition" it do show the seach result but when Double click search result it does not open the source file.

I tested with Notepad++8.4.2 (64 bit) on Windows 10.

DLL name returned has first letter cut off

The call:

data.pszModuleName = DllPath.GetFilename();

sets the module name that gets written to Notepad++ 'config.xml' file. However, the call goes to:

nppgtags/src/Common.cpp

Lines 771 to 783 in ef75856

const TCHAR* CPath::GetFilename() const
{
size_t len = Len();
for (; len > 0; --len)
if (_buf[len - 1] == _T('\\') || _buf[len - 1] == _T('/'))
{
++len;
break;
}
return &_buf[len];
}

where line 778 is wrong - it adds one back to the index of the array (0-based) but you're starting from a Len() (1-based). This results in the following line in Notepad++ 'config.xml' file:

            <PluginDlg pluginName="ppGTags.dll" id="0" curr="3" prev="-1" isVisible="no" />

Missing the leading N.

Cheers.

Add option to make "Find Definition" case insensitive

Wish there were a way to have Find Definition work case-insensitively. For example; doing Find Definition on the string "test_def" would ideally show the definition of "test_def" and "TEST_DEF". This would be useful for browsing poorly-written code in case-insensitive languages, like VHDL.

Add more details to the search result window

Eclipse, when searching for references in a C++ project, shows the following information:

1- Text of the line where the hit has occurred
2- Hit highlighted in bold with a different color
3- Line number of the hit
4- File in which the hit has occurred
5- Name of the function where the hit has occurred
6- Number of hits for each file in which the hit has occurred (format: +main.c (21 matches), +main.h (13 matches)... + is the button to expand/collapse the search results tree)

It appears that NppGTags is correctly implementing point 1 to 4, but it would be very nice to also add point 5 (and maybe 6).

Auto expand all folds

A nice option would be to have auto-expand all folded code in the pop-up window automatically after a new lookup.

Consider adding native Scintilla Autocomplete

Would you consider adding an option (perhaps a checkbox in settings) to use Scintilla autocomplete instead of a plugin "native" version? This would mean that simply typing would also trigger autocompletes (so long as enabled in Notepad++) for tag database items.

Scintilla autocomplete has a lot to be desired and there is not way to integrate with the already existing Notepad++ autocomplete features, but with Scintilla autocomplete, it would "just happen" when typing vs. having to setup yet another shortcut key for autocompletion.

I do something similar in (my fork of) TagLeet.

Cheers.

[Question] Update database outside of NppGtags

It's possible to manually update database by using cmd and get the same result as NppGtags generate (ctags parser)?
Let say I have that folders and files:
D:\Notepad++\plugins\NppGTags\ << here sits all bin/dll/conf files
D:\project\ << root of my code where all database files exist.
Now I want run in cmd bin file from Notepad++ and update database in project. But I don't know what bin file should invoke and how to indicate the source and output as argument.
I don't want update database from NppGtags options because before that action I have to do some other actions and I would prefer to automate all of them.

Add keyword shortcuts to loop through NppGTags search results

It would be cool to have two customizable keyboard shortcuts which could be assigned to:

  • Go to next search result
  • Go to previous search result

The NppGTags search results panel should show the actually selected item by highlighting the corresponding row at every activation of the shortcut (it already happens when manually clicking on the results).

NppGTags not works in windows 10

The NppGTags not works in windows 10 64-bit, however the same environment (NPP 7.7.1 64-bit and NppGTags 4.4.2) works well in Win 7.

Could you add windows 10 support?
Thanks.

How to add .pc extension to C source file indexing?

I have a C project folder. some of them have extension .pc and I want those files to be index as C source code then how can I do it?
for ctags I can use --langmap=C++:+.pc option to include the file.

How can include this for NppGtags?

Parsing of XML files

I'm not sure this would be actually doable in NppGTags, but here I go. I was trying to index this XML file:

<?xml version = "1.0" encoding = "utf-8"?>

<!-- planes.xml - A document that lists ads for 
                  used airplanes -->

<!DOCTYPE planes_for_sale SYSTEM "planes.dtd">
<planes_for_sale>
   <ad>
      <year> 1977 </year>
      <make> &c; </make>
      <model> Skyhawk </model>
      <color> Light blue and white </color>
      <description> New paint, nearly new interior,
            685 hours SMOH, full IFR King avionics </description>
      <price> 23,495 </price>
      <seller phone = "555-222-3333"> Skyway Aircraft </seller>
      <location>
         <city> Rapid City, </city>
         <state> South Dakota </state>
      </location>
   </ad>
   <ad>
      <year> 1965 </year>
      <make> &p; </make>
      <model> Cherokee </model>
      <color> Gold </color>
      <description> 240 hours SMOH, dual NAVCOMs, DME, 
                new Cleveland brakes, great shape </description>
      <seller phone = "555-333-2222"  
              email = "[email protected]">
              John Seller </seller>
      <location>
         <city> St. Joseph, </city>
         <state> Missouri </state>
      </location>
   </ad>
</planes_for_sale>

but it seems that NppGTags doesn't detect any tag (the same applies to tag values, and so on). I don't know if this classifies as an issue or not, I was just curious to know if there was a way to index the nodes, id's, and values of an XML file with NppGTags, given that Pygments allegedly seems to support that:

http://pygments.org/docs/lexers/

Add some functions to the "Search in results" panel

It would be extremely useful to transform the search result window so that it could behave like this:

Automatically filtering of search results when typing the search expression

Example:

Let's consider a search result of this kind:

Find Symbol "CLR" (literal, match case) in "C:\Encoder\"
	CRC_Check.vhd
		line 131:	CLR		: in std_logic;
		line 201:	CLR		=> IMAGELINESTART,
	CRC_Encoder.vhd
		line 42:	CLR		: in std_logic;
		line 63:	if (CLR = '1') then

If I type the character "=" in the filter box, then the results would become:

Find Symbol "CLR" (literal, match case) in "C:\Encoder\"
	FCA_Check.vhd
		line 201:	CLR		=> FCALINESTART,
	FCA_Encoder.vhd
		line 63:	if (CLR = '1') then

If I also add a ">" to the filter box appending it to the already typed "=", it would automatically become:

Find Symbol "CLR" (literal, match case) in "C:\Encoder\"
	CRC_Check.vhd
		line 201:	CLR		=> IMAGELINESTART,

So this kind of filtering would be useful for example to look for special code statements (for example, ports, signal assignments, arrays, defines...).

Moreover, an option could be added to save some user customizable filters which could be used between sessions (for example by selecting them through a listbox).

Finally, it would be great to make the selected filter persistent so that at every search, the results are automatically filtered, if chosen to do so.

This would make NppGTags code browsing even more powerful, in my opinion.

store database in user folder

Is it possible to move generated files of the database in a user folder ?
The aim is to keep a repository clean when this reporistory is parsed by nppgtags.

example
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GPATH_1
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GRTAGS_1
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GTAGS_1
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GPATH_2
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GRTAGS_2
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GTAGS_2
......
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GPATH_x
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GRTAGS_x
C:\Users\XXXXXX\AppData\Roaming\Notepad++\plugins\nppgtags\GTAGS_x

Occur "vector<T> too long" with Notepad++ 8.4 and later

I got "vector too long" warning dialog on Npp 8.4 and later when I use "Find definition" of NppGTags, but 8.3.3 is work fine, Wish who can help fix that, this is good plugin for me.

image

Notepad++ v8.4.2 (32-bit)
Build time : May 29 2022 - 16:45:17
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Command Line : โ€œ\MXUSER4\www\StockCafe\Workplace.nppโ€
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 21H2
OS Build : 19044.1766
Current ANSI codepage : 950
Plugins :
NppGTags (4.5)

Python 3 and pygments-parser.py

On Python 3, the pipe between pygments-parser.dll and pygments-parser.py will not work.
Because the dll create Ansi Pipe, pygments-parser.py uses stdin.readline(), but on Python3, stdin.readline() read Unicode chars.
Please test them.
Thanks.

Additional infos on readme

Doesn't it make sense to add the link to the win32 libs (http://adoxa.altervista.org/global/) directly to the readme. I was not able to find that link on the GNU page.
Current version is 6.6.9. How is your strategy on updating these? Might be also of interest to add the currently used version to the readme if someone is missing a new feature/bugfix.

ctags' extend is not supoort in windows

I extend ctags to support our DSL.

# pattern list
--langdef=t2k_plist
--map-t2k_plist=+.plist
--kinddef-t2k_plist=g,Pattern,Pattern
--regex-t2k_plist=/^Pattern[ \t]*([a-zA-Z0-9_]+)/\1/g/

and save those content to ctags config file.
when I run ctags from command line, it works.

but when I run npptags from notepad++(change setting to ctags), it's not work.

could you please check it?

thanks.

New Universal Ctags version available

Hi, I noticed that your Universal Ctags latest included version is the following:

Universal Ctags 0.0.0, Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jan  1 2016, 11:12:30
  URL: https://ctags.io/

It seems that a new Universal Ctags has been very recently released here:

https://github.com/universal-ctags/ctags-win32/releases

Just in case you would think about integrating it on your next release. Maybe it adds compatibility with many other programming languages.

Add more settings and functions to the search result window

Actually when searching for a reference, the results are always shown in a collapsed tree. Please add a setting to change this behavior.
For example, in many cases it would be better to always show the search result tree already expanded.

Two customizable shortcuts for expanding/collapsing the search results tree would also be nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.