Giter Site home page Giter Site logo

Comments (5)

nyamatongwe avatar nyamatongwe commented on July 17, 2024

Namespaces are supposed to be optional - you don't have to specify them if you are willing to receive a lexer with that name from any library. If you specifically want the Lua lexer can't you ask for lexer.$(file.patterns.name)=lpeg.name?

from lexilla.

nyamatongwe avatar nyamatongwe commented on July 17, 2024

Which library is not providing a namespace? Lexilla as installed into SciTE should be using "lexilla" and Scintillua should be using "lpeg".

from lexilla.

ittegrat avatar ittegrat commented on July 17, 2024

My use case is the following: I would use the Lua lexer for a private DSL language and the standard Lexilla lexers for all the other files. I encounter the problem using Sc1. As far as I understand, the problem doesn't occur in SciTE because the lexilla.dll is probed before the LexLPeg.dll.
A minimal set of properties to reproduce the problem is the following:

SciTEGlobal.properties

import lexers/lpeg

lexers/lpeg.properties

lexilla.context.lpeg.home=$(SciteDefaultHome)/lexers
lexilla.context.lpeg.color.theme=scite
if PLAT_WIN
  lexilla.path=.;$(lexilla.context.lpeg.home)/LexLPeg.dll
if PLAT_GTK
  lexilla.path=.;$(lexilla.context.lpeg.home)/liblexlpeg.so
fold.by.indentation=0
fold.line.groups=0
fold.on.zero.sum.lines=0

With these settings, I would expect a file, e.g. a python file, to be styled with the static Lexilla lexer set in the embedded properties, but instead, it is styled with a default lpeg lexer.
I tried to to set the namespace, i.e. lexer.$(file.patterns.py)=lexilla.python, but is is not recognized. Does the static lexilla library define the namespace?.

from lexilla.

nyamatongwe avatar nyamatongwe commented on July 17, 2024

The statically linked lexers are checked after the dynamically loaded lexers and don't have a namespace. You could grab a copy of Lexilla.dll from a full SciTE download and refer to it in lexilla.path.

There could be a second try of the static call inserting "lexilla." before the name.

from lexilla.

nyamatongwe avatar nyamatongwe commented on July 17, 2024

This patch implements a static namespace that refers to statically linked lexers with statements like lexer.*.cpp=static.cpp. That then requires the static. name in other properties style.static.cpp.4=$(colour.number).

diff --git a/access/LexillaAccess.cxx b/access/LexillaAccess.cxx
index f612ce29..2a4b6450 100644
--- a/access/LexillaAccess.cxx
+++ b/access/LexillaAccess.cxx
@@ -234,6 +234,10 @@ Scintilla::ILexer5 *Lexilla::MakeLexer(std::string_view languageName) {
 			}
 		}
 	}
+	constexpr std::string_view builtin("static.");
+	if (HasPrefix(sLanguageName, builtin) && pCreateLexerDefault) {
+		return pCreateLexerDefault(sLanguageName.substr(builtin.size()).c_str());
+	}
 	// If no match with namespace, try to just match name
 	for (const LexLibrary &lexLib : libraries) {
 		if (lexLib.fnCL) {

The static namespace is probed after the dynamically loaded lexer's namespaces but before checking for names without namespaces.

from lexilla.

Related Issues (20)

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.