yoshiki / yaml-mode Goto Github PK
View Code? Open in Web Editor NEWThe emacs major mode for editing files in the YAML data serialization format.
License: GNU General Public License v3.0
The emacs major mode for editing files in the YAML data serialization format.
License: GNU General Public License v3.0
RECRUITMENTS I have not used emacs and this library for a long time, so I recruit maintainers or collaborators for all yaml-mode users. If you are interested in maintaining or collaborating with this library, please contact me. NAME yaml-mode - Simple major mode to edit YAML file for emacs REQUIREMENTS Emacs 24.1 SYNOPSIS To install, just drop this file into a directory in your `load-path' and (optionally) byte-compile it. To automatically handle files ending in '.yml', add something like: (require 'yaml-mode) (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)) to your .emacs file. Unlike python-mode, this mode follows the Emacs convention of not binding the ENTER key to `newline-and-indent'. To get this behavior, add the key definition to `yaml-mode-hook': (add-hook 'yaml-mode-hook '(lambda () (define-key yaml-mode-map "\C-m" 'newline-and-indent))) DESCRIPTION yaml-mode is major mode for emacs. INSTALL You can install yaml-mode typing below. % make % make install or % make PREFIX=/your/home/dir % make install PREFIX=/your/home/dir SETTING see SYNOPSIS. AUTHOR Yoshiki Kurihara <[email protected]> Copyright (C) 2010 by Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
When *.el
files are compiled, they produce *.elc
files, which should be ignored. Please add a line to your .gitignore to ignore *.elc
files. (I use your project as a submodule in my Emacs config)
Hello,
I've seen your recruitment call and am interested in maintaining and
hacking on yaml-mode. Do you have any specific plans in mind?Cheers
Vasilij
foo: # comment
|
# refuses to go to next indent level
Shouldbe: # comment
| |
I installed YAML from elpa. From tromey.com, I believe. That version seems to be very old and doesn't include autoloads, so it basically doesn't work at all. Can you upload a more recent version? I know your github version contains autoloads now. Thanks for your hard work!
My descriptions end up containing solo single quotes (') and text quotes ("), usually inside backticks or parentheses. These end up flipping the state of the description's string highlighting. In the following examples "oops" should not be highlighted like a string.
description: |
'quoted' and "quoted" and '"' and "'" and `'` oops
# ' <-- reset
description: `"` oops
#" <-- reset
I have two fixes. One adds a backtick to the syntax entry for a string quote so that `this` ends up highlighted, and the other causes no ' or " to start a string if it is preceded by non-space. While they work for me, they may be a bit drastic for the package proper so if I end up submitting a PR, it will speculative, maybe to serve as inspiration for something better.
I get this error when I start up my emacs with yaml-mode.el.
Debugger entered--Lisp error: (error "Unknown keyword :safe")
signal(error ("Unknown keyword :safe"))
error("Unknown keyword %s" :safe)
custom-handle-keyword(yaml-indent-offset :safe natnump custom-variable)
custom-declare-variable(yaml-indent-offset 2 "*Amount of offset per level of indentation." :type integer :safe natnump :group yaml)
(defcustom yaml-indent-offset 2 "*Amount of offset per level of indentation." :type (quote integer) :safe (quote natnump) :group (quote yaml))
eval-buffer(#<buffer load<2>> nil "/Users/ocarlsen/.emacs.d/lisp/yaml-mode.el" nil t) ; Reading at buffer position 2673
The following snippet is weirdly highlighted. The second embedded (") character is considered a start of a string and is highlighted red until the next item in the collection:
before_script:
- |
case "$CXX" in #(
g++*) CXX=g++-5.2 #(
;;
clang++*) CXX=clang++-3.7
;;
esac
- |
case "$CC" in #(
gcc*) CXX=gcc-5.2 #(
;;
clang*) CXX=clang-3.7
;;
esac
Hi, I noticed that master at 831ef3a is 23 commits ahead of 0.0.14, and these seem like bugfixes that you'll want users to have access to. At this time, in Debian, we're preparing for the "freeze" where new versions of software cannot be imported. Would you please consider tagging a release before Christmas if you'd like Debian stable users to have access to newer than 0.0.14?
Thanks,
Nicholas
Put into test.yaml
the following (sorry, attaching test.yaml failed)
##
## (1) open this file
##
## (2) move to the line containing l1
##
## (3) Press TAB. First character of l1 should now be below '|', but
## it is below the dash, i.e. not indented wrt the dash.
##
- bb:
- |
l1
This will make it inherit everything from prog-mode, including modifications made by distributions like https://github.com/bbatsov/prelude .
I've discovered an highlighting error when dealing with inline lists (see image). I've narrowed down the issue to the yaml-nested-sequence-re regex, but have not found a way to fix the problem.
So speedbar and imenu can display it
This bug:
This is especially troublesome with docker-compose.yml
file where you define port mappings like:
services:
grafana:
image: grafana/grafana
ports:
- '3000:3000'
I have no idea how to investigate/fix this myself, so I'm asking for help (please) ๐ !
EDIT: see #82 (comment) below for an investigation done by @sulami.
yaml-mode
's derivation from text-mode
causes my configuration to require more special-case hooks (and "unhooks") for yaml-mode
than any other mode.
reST, HTML, Markdown, etc. (used to justify this derivation in #27) are markup languages. A document is primarily text intended for direct reading, surrounded by formal markup. YAML is, as it states, not. It's a language specifying structure, sometimes containing human-readable text (but often not).
I don't want to spellcheck anything but comments. I don't want to electrify any quotes or typographic punctuation. I want flycheck to complain loudly about syntax errors. In every respect, I want to act like a prog-mode.
The yaml file
backgroundOrder:
- 13
- 44
backgroundStates:
- 9
- 10
columnOrder:
- ICON
- DISTANCE
is converted to
backgroundOrder:
- 13
- 44
backgroundStates:
- 9
- 10
columnOrder:
- ICON
- DISTANCE
The title speaks for itself. What is the reason that you decided to inherit from fundamental-mode
? Some people (including me) have things like
(add-hook 'text-mode-hook 'fci-mode)
(add-hook 'prog-mode-hook 'fci-mode)
which make life easier, and that's exactly one of those features what proper mode inheritance was intended for.
Thank you.
Instead of this:
password: |
-----BEGIN PGP MESSAGE-----
BLAH
-----END PGP MESSAGE-----
I get this:
password: |
-----BEGIN PGP MESSAGE-----
BLAH
-----END PGP MESSAGE-----
Wishlist:
In deeply nested YAML files, sometimes I get a bit lost. A way to make yaml-mode display which nested map I'm in would be wonderful!
Show-Paren is very useful when editing code in Yaml Block scalars. Unfortunately, it doesn't display the parenthesis matches.
Is there any reason to modify the yaml-mode syntax table with these 2 characters :
(modify-syntax-entry ?\( "." syntax-table)
(modify-syntax-entry ?\) "." syntax-table)
Show-Paren needs this syntax to highlight parentheses :
(modify-syntax-entry ?\( "()" yaml-mode-syntax-table)
(modify-syntax-entry ?\) ")(" yaml-mode-syntax-table)
Thanks
PR #57 fixed apostrophe inside a word. But it broke quote handling when the previous letter is not a space. I originally didn't think of any cases where well formatted YAML quote was not prefixed with a space, but JSON style dictionaries and lists are one.
e.g.
key: ['key2': value]
Either the apostrophe detection code should handle {
and [
the same way as the whitespace. Or it should detect the apostrophe case by checking if the previous character is any unicode letter.
It would be nice to be able to pull this from the main package repositories (Emacs 24+)
I think yaml-mode should make a release. I'd like to volunteer to help.
ac21293 says we want to filter out comments, and changed .
to [^#]
. However .
is defined as "any single character except a newline", this change causes the match to run for many lines and breaks indentation when editing in the middle of a document. Maybe this should be [^#\n]
; or is there a way to tell looking-at
to consider only one line?
For example, if you're trying to place a GPG-encoded block in a block literal, the following happens:
test: |
-----BEGIN PGP
Without unindenting the second line, it returns to the start of the line as soon as you type the third dash.
yaml-mode 0.0.13, GNU Emacs 25.1.1
It would be nice to have an org-mode style folding for nested keys.
When leaving a block literal to continue a dictionary definition, the rest of the dictionary is font-locked as a string.
This implies that the rest of the dictionary is part of the string literal, which is not true.
In [5]: yaml.load('''
...: - text: >-
...: This is a block literal with font-lock spilling out
...: a: 1
...: b: 2
...: c: {}
...: ''')
Out[5]:
[{'a': 1,
'b': 2,
'c': {},
'text': 'This is a block literal with font-lock spilling out'}]
This is new behavior.
The addition of comment symbols seems to "fix" the issue.
However, when the comment symbol is deleted, the font-lock spills back in:
Hi,
Is the following construction going to be supported (and properly indented)?
title:
-
- foo_1: bar_1
foo_2: bar_2
-
- foo_3: bar_3
foo_4: bar_4```
yaml-mode has a binding for C-j but it's the default binding (newline-and-indent). There's no need for it for people who use C-j as the default, and for people who don't use it as the default, it breaks their binding if it's not set via a minor mode.
Personally I bind Enter to newline-and-indent and reuse C-j for something else, but yaml-mode clobbers my binding, since it's not in a minor mode.
The addition of this :safe might be useful
(defcustom yaml-indent-offset 2
"*Amount of offset per level of indentation."
:type 'integer
:safe #'(lambda (x) (and (integerp x) (< -1 x 11)))
:group 'yaml)
yaml-mode has several releases, but unfortunately uses a tag naming scheme that is incompatible with MELPA's logic for identifying stable packages:
Stable Packages
MELPA now includes a mechanism to build stable versions of packages given that the repositories meet the following criteria,
- Hosted using git or hg.
- Tag names are version strings compatible parseable by the
version-to-list
function, optionally prefixed withv
,v.
orv-
.
Your release tags are prefixed with release-
, making MELPA not recognize them. The rest of the version string is already compatible with version-to-list
:
(version-to-list "0.0.10")
=> (0 0 10)
Please consider
v-0.0.10
, to the latest release so that MELPA stable will build it, andAs of YAML 1.2, YAML is an official super of JSON (https://yaml.org/spec/1.2/spec.html), however yaml-mode formats JSON like:
{
"language": "nix",
"nix": "2.1",
"matrix": {
"include": [
{
"name": "cargo pedantry",
"script": "nix-shell --run checkPhase --arg useNix1 false -A mozilla-rust-overlay"
},
{
"name": "checkPhase",
"script": "nix-shell --run checkPhase --arg useNix1 false"
}
]
}
}
A comment like this stays the same after indenting the whole buffer:
# some comment
# lots of things
# more info
but adding a :
and indenting the whole buffer causes indentation to change:
# some comment:
# lots of things
# more info
I understand that yaml has a complex specification, so you might not be able to do much about this.
See the relevant issue on glynnforrest/salt-mode#19.
I have a large yaml file of amount of 3M bytes. I was kept waiting 8 seconds when opening this file.
I found that font-lock-fontify-buffer
is called in yaml-mode
. It is very slow because jit-lock is not activated at major mode called time.
I remove font-lock-fontify-buffer
from yaml-mode
, it became quite fast.
Why is font-lock-fontify-buffer
called in yaml-mode
?
I installed yaml-mode
from Melpa stable version ``. I don't know exactly when this happens, but in some YAML files, when I hold <down>
, it makes emacs use 100% CPU. This does not happen when opening a YAML file in an emacs instance started with `emacs -Q`. In that case these is no special `yaml-mode` and no such CPU usage happens when scrolling through the file. I could not construct an example file yet to make this more reproducible.
It seems there is some unusual computation going on when pressing down.
example is here:
https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
from line 631, render color is broken.
Thanks
Emacs is lag, and stop to work, CPU usage is 100% ......
And move point is very lag, edit is never possible.
BTW: this is a yml file which have I18n information.
I don't have an example file, but it's a typical VCR cassette recording with lots of JSON contents inside strings (meaning lots of quote characters).
(benchmark 1 '(progn (syntax-ppss-flush-cache (point-min)) (syntax-ppss (point-max))))
Prints out ~23 seconds in a 14000 line file.
Here's a profiler output after a lot of scrolling (which is very laggy):
- command-execute 4860 76%
- call-interactively 4860 76%
- apply 4859 76%
- call-interactively@ido-cr+-record-current-command 4859 76%
- apply 4859 76%
- #<subr call-interactively> 4859 76%
- funcall-interactively 4859 76%
- cua-scroll-up 4679 74%
- scroll-up 4416 69%
- jit-lock-function 4354 68%
- jit-lock-fontify-now 4354 68%
- jit-lock--run-functions 4347 68%
- run-hook-wrapped 4347 68%
- #<compiled 0x156f9ba524b9> 4346 68%
- font-lock-fontify-region 4346 68%
- font-lock-default-fontify-region 4345 68%
- font-lock-fontify-syntactically-region 3657 57%
- syntax-propertize 3442 54%
- yaml-mode-syntax-propertize-function 3411 53%
- syntax-ppss 3337 52%
#<compiled 0x156f9ba6f345> 1 0%
With yaml-indent-offset set to 4, I get a tab in the second level of indentation, e.g.
entry:
first:
- 'second'
When I press to indent for "first", it works correctly. When I press to indent for "- 'second'" the cursor jumps to the correctly place, but inserts a tab instead of 8 spaces. Setting indent-tabs-mode to nil in the mode hook makes it work correctly. IMO, it should work out-of-the-box ;-)
Many thanks!
When I try to write yaml file with 5 levels, 5th level's indentation becomes TAB character instead of 8 space characters. For example, in case of below, the TAB character is preceding "Lorem ....". According to YAML specification, TAB is not allowed for level indentation.
en:
app:
welcome:
body:
Lorem ipsum dolor sit amet consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
Add this:
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))
I have those yaml
search_page_pages_count_css: div#pagin-btm span.page-skip em
I think #pagin-btm span.page-skip em
face look like a comment is strange.
Thanks.
I'm seeing the following indentation behaviour when using yaml-mode:
foo:
- bar: baz
- foo: 1
I yaml-mode to indent like:
--- expected
foo:
- bar: baz
- foo: 1
This seems to be related to yaml-nested-sequence-re
and the way it is being used in yaml-compute-indentation
as either of the following changes fixes/changes this particular behaviour:
yaml-nested-sequence-re
to only match lines that end with :
The following regular expression results in the "correct" behaviour in this particular case.
(defconst yaml-nested-sequence-re
(concat "^\\(?:\\(?: *- +\\)+\\|\\(:? *-$\\)\\)"
"\\(?:" yaml-bare-scalar-re " *:\\)?$")
"Regexp matching a line containing one or more nested YAML sequences.")
Unsurprisingly removing the yaml-nested-sequence-re check from yaml-compute-indentation to yield the following also results in the correct indentation of the snippet above.
(defun yaml-compute-indentation ()
"Calculate the maximum sensible indentation for the current line."
(save-excursion
(beginning-of-line)
(if (looking-at yaml-document-delimiter-re) 0
(forward-line -1)
(while (and (looking-at yaml-blank-line-re)
(> (point) (point-min)))
(forward-line -1))
(+ (current-indentation)
(if (looking-at yaml-nested-map-re) yaml-indent-offset 0)
(if (looking-at yaml-block-literal-re) yaml-indent-offset 0)))))
Paired with #24 it appears as if the indentation framework needs to be more context sensitive like python-mode.
Can we get a new version on marmalade please?
Hello,
I'm trying to change colors using custom-set-faces,
But I have not achieved it, what would be the way to do it, to get a different color combination than I have in the emacs theme ...?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.