Code Monkey home page Code Monkey logo

modern-cpp-font-lock's People

Contributors

condy0919 avatar ludwigpacifici avatar mola-t 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  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  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  avatar  avatar  avatar  avatar

modern-cpp-font-lock's Issues

Raw strings do not work

The documentation suggests that raw strings should be properly highlighted, but this does not seem to work. To reproduce this, I started from a completely clean .emacs file and then ran:

(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-refresh-contents)
(package-install 'modern-cpp-font-lock)
(modern-c++-font-lock-global-mode t)

I then opened a new C++ file, verified that modern-c++-string-literal was indeed t, but unfortunately still do not get proper highlighting:

mfl

Add support for raw string literals?

The regexs here seem to work once you apply the correction from the comments, so something like:

(font-lock-add-keywords
 nil 
 '(
       ("\\(\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\)" 1 font-lock-keyword-face t) ; start delimiter
       (   "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\([[:ascii:][:nonascii:]]*?\\))[^\\s-\\\\()]\\{0,16\\}\"" 1 font-lock-string-face t)  ; actual string
       (   "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}([[:ascii:][:nonascii:]]*?\\()[^\\s-\\\\()]\\{0,16\\}\"\\)" 1 font-lock-keyword-face t) ; end delimiter
   ))

`concept` keyword

Thanks for this package. Could you add the concept keyword at your convenience? Thank you

expected to work with GNU Emacs 25.2.2?

I'm using stock Ubuntu 18.04, which has this version of emacs. When I do the following:

M-x package-install [RET] modern-cpp-font-lock [RET]

I get this in the Messages buffer.

Contacting host: melpa.org:80
package-install-from-archive: http://melpa.org/packages/modern-cpp-font-lock-20180110.2031.el: Not found

Templates

Highlighting template parameters have been one thing that have never worked consistently for me in emacs. I tried installing modern-cpp-font-lock, but I'm still getting the following hightlighting:

image

The template paramters Features and Model are not hightlighted, but above State is.

Any ideas for how to fix this?

Installation from Melpa fails with compilation error

Compiling file /home/[[redacted]]/.emacs.d/elpa/modern-cpp-font-lock-20160527.1440/modern-cpp-font-lock.el at Wed Jun 1 11:43:53 2016
modern-cpp-font-lock.el:129:188:Error: Symbol's function definition is void: modern-c++-string-lenght>

The Github repository seems to have commits after the Melpa date, so I'm not sure if this is still current.

if constexpr indent

From c++ 17, if constexpr statement is introduced but its indentation looks collapsed like this.

if constexpr (true) {
        f();
    }

Maybe your mode does not support indentation. I wonder if you have any solution for this problem (adding keywords or something).

Raw string literal isn't handled correctly.

Raw string literal isn't handled correctly (especially with embedded double quote character). Example:

int main(int argc, char** argv) {
  std::cout << R"(foo"bar)" << std::endl;  // "(foo" is highlighted as string, plus everything after )"
  std::cout << R"foo(foo"bar)foo" << std::endl;  // everything up to R" is highlighted, and "bar)foo"
  return 0;
}

Using emacs version 25.3.1.

Trouble with attributes

When I give a function an attribute, the function name is no longer fontified.
When I write a function:
int myfunction() { /*...*/ }
it is fontified correctly. But if I add any attribute:
[[nodiscard]] int myfunction() { /*...*/ }
the function name myfunction is now just the default text color. This happens with multiple

trouble with string literals

I'm using stock Ubuntu 18.04. I creates a simple setup without any of my init, and I cannot get the color of this small c++ program to work correctly.

#include <string>
std::string a = R"raw(Hi there I'm a Qoute " guy)raw";
int main(){}

Everything after the end double quote on line 2 is colored as if it were inside a string. It does not seem to recognize the double quote before guy as being inside the string.

I'm running emacs like this:

emacs -q --load testinit.el

the contents of my init file (testinit.el) are:

(add-to-list 'load-path "/home/mat/tmp/cppfl/modern-cpp-font-lock")
(require 'modern-cpp-font-lock)
(modern-c++-font-lock-global-mode t)

I've cloned a copy or your repo here, at revision 02f1047. The test directory, /home/mat/tmp/cppfl, looks like:

a.out
modern-cpp-font-lock/
t.cpp
t.cpp~
testinit.el

I'm on emacs 25.2.2.

ObjC support

Any plans for ObjC(++) as well (because based on same libClang?

clash between modern-c++-font-lock-mode and built-in c++-mode

Example code:
void f() { aut s = R"EOF("a)EOF"; }
If I set fundamental-mode and enable modern-c++-font-lock-mode then the raw string is highlighted perfectly so the modern fontifying is working. However if I set c++-mode then modern-c++-font-lock-mode then it is highlighted the old C++ way - it looks like the built-in c++ fontification is over-riding the modern rules.

To reduce uncertainty I ran this with emacs --no-init so no other ealpa packages are loaded:
(load-library "~/.emacs.d/elpa/modern-cpp-font-lock-0.1.3/modern-cpp-font-lock.el")
Using CC Mode version 5.32.99
GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.26) of 2018-01-12

I can try to debug this but I'd like some hints where to look. I'm familar with elisp programming but not the font-lock stuff specifically.

Integration with RTags

Hi Ludwig, I'm back again!

I just saw this thread Andersbakken/rtags#677 and am really curious to know if there has been any progress to integrate modern-cpp-font-lock and rtags. This would be a fantastic feature!

Hexadecimal digits prefix highlights as keyword

image

It can be reproduced using the following init.el with emacs -Q -l init.el.

(require 'package)
(setq package-archives
      '(("gnu"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
        ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))

(package-initialize)

;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))

(use-package modern-cpp-font-lock
  :ensure t
  :hook (c++-mode . modern-c++-font-lock-mode))

(provide 'init)

emacs --version

GNU Emacs 28.0.50
Copyright (C) 2020 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

cc-mode version

;; Version: 5.33.1

After reading the source, it seems like a feature but a bug.

https://github.com/ludwigpacifici/modern-cpp-font-lock/blob/master/modern-cpp-font-lock.el#L186

second function argument type is rendered as a variable

The function declarations below highlight ABC as a function variable instead of a type
void foo(std::string&, ABC);
void foo(string s, ABC abc)
However
void foo(string&, ABC);
and
void foo(std::string, ABC);
correctly hightlight ABC as a type.

My modern-cpp-font-lock version is 0.1.3 installed from Melpa, emacs version is 24.5.1 the system is emacs Would you please investigate this problem? Thank you!

Modern C++ indentation?

I am completely tired of Emacs messing up auto-indentation with some of the modern C++ features, such as strongly-typed enums (ie. "enum class ..."). It's highly annoying. Therefore I was hoping that this font-lock would fix those issues, but does not.

Would it be possible to fix the indentation problems that the current official cc-mode has?

tries to compile/load the test file

When attempting to install the latest version from MELPA, I get an error because it tries to load faceup.el from ~/.emacs.d/faceup/faceup.el which AFAIK is because of the recent inclusion of tests. I think perhaps the test files need to be excluded from the MELPA definition for the package?

Does this package support C++20 features?

(I am not a native English speaker, so my problem may be due to lack of knowledge on my part.)

When I read the primary description of what this package is about:

Syntax highlighting support for "Modern C++" - until C++20 and Technical Specification.

I am left with the question whether or not this package supports C++20 language features. The semantics of the English word "until" seems to be exclusive and not inclusive (according to Dictionary.com).

This would mean that this package does not support C++20 features. Is that indeed the intended reading of this package description?

Integer literal font lock

I'm having some issues with the interger literal when using the single quote. I grabbed the examples from your test file.

Here is what I get with modern cpp mode enabled.

screenshot from 2018-03-10 13-22-12

Here is what I get with modern cpp mode disabled.

screenshot from 2018-03-10 13-25-23

Highlighting numeric literals

First off, I should say, this has been a really helpful package. Really nice to have the improved highlighting. Makes editing that much easier!

When there are numerical characters in a function name or variable name, if they follow an underscore, start with zero, and have at least one additional digit then they are highlighted as a literal.

image

You can see that it doesn't happen without the underscore. Also, if it is just a zero or if there is no zero then it is also okay.

Support for digit separators?

Are there plans to support to support digit separators in this library? C++14 supports using single quotes as digit separators but this messes up the font-locking quite badly when using the default C++ mode or this library.

Font lock for function calls

I tried looking int he source code but it doesn't seem function "calls" from inside other functions has an option for a highlight.
is that correct? or did I miss something?
If it is the case, is it possible to add this support? I feel that highlighting function calls in specific helps great deal in understanding any new code.

"const override" is not correctly highlighted

Thank you for this package.

Using c++-mode and modern-c++-font-lock-mode the following code

struct b : public a
{
  void foo() override;
  void foo() const override;
};

is font-locked as

comp

as if the second override was not detected as a keyword.

Would that be easy to fix?

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.