This is needed because users could try to enable plugins with
`config.plugins.plugin_name = true`.
Before, this would result in `common.merge` throwing an error; now it
just returns a copy of the "base" table.
Since the linewrapping plugin modifies some of the DocView line
calculation and positioning functions we need to make sure of loading it
before other plugins. This way we make sure that plugins that also overwrite
and depend on DocView functionality aren't using the original methods without
the linewrapping changes, which leads to wrong line and column calculations.
The number of results from a pattern with groups must never be greater
than the number of token types for that pattern.
Also if a token type was undefined, it's now pushed as a `normal` one.
Before, this was only supported by Lua patterns.
This expects the regex to use the same syntax used for patterns. That
is, the token should be split by empty groups.
* Modified autoreload to use new dirwatch infrastructure, and added in nagview to verify that fs changes don't stomp on our changes, unless you want them to.
* Split out reload functionality to actual document, and added in a thread to check the document, in the cases where it wouldn't be covered by dirwatch.
* As per request from jgmdev, added in ability to show nagview always.
* Changed things over to use dirwatch.
* Made sure we redrew things, added in a contingency in 'save' for times when we load a non-existent file, and added some checks.
* Prevent adding duplicate bindings
* Clean reverse_map on overwrite or add direct
* Added get_bindings to complement get_binding
* Added doc comments for easier comprehension
* Check if command is function on add_direct
Currently some plugins had/have issues with predicates that check
if active view is a docview to perform certain operations like draw
in the case of minimap or lineguide. Since is() was checking the
entire inheritance tree it was returning true for views that inherit
from the same parent, which caused CommandView to be matched along
DocView, etc... This change does the following to solve the issue:
* Make Object:is() only match the top level parent of the object which
is more in line with what one would expect from a method named 'is'.
* Introduces Object:extends() which keeps the same functionality that
Object:is() offered before.
* Change to 1 click as per RFC on discord, with 100% in favour.
* Added in the ability to specify as a view name, so it doesn't modify the title, and also fixed a bug where if you clicked *over* the amount of times your config says, it wouldn't regsiter.
* Changed plugin to use keymap.
Using `get_active_node` might result in a locked `Node`; calling
`add_view` on that `Node` throws an error.
`get_active_node_default` always returns an unlocked `Node`.
* Send `mouseleft` event when the mouse leaves the window
* Call `View:on_mouse_left` when the mouse leaves the `View`
Previously `View:on_mouse_left` was called only when the mouse left the
window, and it was called on every visible `View`.
Now it gets also called when the mouse "changes" `View`, and only the
last `View` the mouse was on will receive the event.
Before the addition of multi-cursor support, we just returned the second
return value of the "replacer" function to the caller.
With the introduction of multi-cursors, we naively summed the second
return values for each cursor.
In some cases the "replacer" function doesn't return any second value,
so we tried to do math with `nil`, thus throwing errors.
Now the second return value is added to a table which is then returned
to the caller.
* Change to 1 click as per RFC on discord, with 100% in favour.
* Added in the ability to specify as a view name, so it doesn't modify the title, and also fixed a bug where if you clicked *over* the amount of times your config says, it wouldn't regsiter.
* Changed plugin to use keymap.
This allows `keymap.add` to map shortcuts to functions.
If the function returns `false`, the next command is executed (as if the
`predicate` of a `command` failed).
Add configuration options to specify:
- characters to substitute and their substitution;
- whether to substitute at the beginning, middle or end of the line;
- the color of the substitution;
- the color for the beginning, middle or end;
- the minimum number of white space to show in the middle.
* Introduces a flag that syntax writers can turn off named
space_handling, turning it off means that your syntax will take care
of handling the excessive amount of spaces that can slow down the
tokenizer.
* Adds another pattern at the end of every single table that also
improves tokenizer performance by matching words that weren't match by
any of the synxtax patterns.
* Modifies language_md to turn off the provided space_handling and do its
own since it has rules that require a space at the beginning, also
handles long consecutives amount of dashes used in tables that degrade
performance.
* This changes where discussed in collaboration with @Guldoman and
@takase1121 thanks to all!
* support colorization of function and variables type declarations
* support the macro concatenation operator ##
* support what seems to be new cpp number notation format #'###
* improved uppercase constants matching
* fix delete_temp_files() deleting in EXEDIR but temp_filename() was
creating temp files in USERDIR
* make delete_temp_files() public so it can be used by plugins
* add optional `dir` parameter to both delete_temp_files() and
temp_filename() to allow specifying a different directory, this is
for example useful when generting markdown previews, the temp file
should be generated in the project dir in case the readme references
images that are relative to it, so the web browser can find them.
* mainly the language_md got affected which has some exotic rules
* some other languages are also using spaces at start of pattern
and even if not affected this change tackles that
When using `doc:move-to-{previous,next}-char` in a selection, we were
moving the cursor to the character before the initial/after the last
character of the selection.
Now we follow what other editors do and move it to just before the
initial/just after the final character.
* Improved performance 67x by not using the tokenizer, this means that
now opening files or saving them where indentation is re-detected
is much more faster.
* Improved the algorithm to detect the space size.
* Do not compete with language_cpp.lua over the .h and .inl files,
these files can contain both cpp and c so we choose the former which
supports both syntaxes.
* Added support for magic and uppercase constants.
* Removed pcall(require, "plugins.language_c") since it doesn't works
as it seems to have been intended.
* Removed duplicate keywords
* Added support for magic and uppercase constants.
* Basically merged most changes from the lite-xl-plugins repo.
This new config flag ignores the plugins version check at startup
which helps a lot when working on new or old plugins that doesn't match
the mod or lite-xl version and you still desire to load them to fix them
by checking with lite-xl it self which errors need to be corrected.
Also some other minor changes:
* fix transition when nagview is closed
* do not draw or update when not visible
* do not process events when not visible
* cleaned a bit the logic on next and show
* fixes#848
When a user modifies and saves the init.lua or a project module file the
reload_customizations() function was performing unnecessary reloading
of core.config and core.style. This resulted on the replacement of config
tables with new tables, breaking all active references been used by
the consumers of this config options. Been redundant this means
that every consumer was using its own copy of a configuration table
different from the one referenced on core.config and user changes not
taking place.
* Fixed some issues with inotify and multiple events at the same time. Seems to be working now.
* Cleaned up and simplified function, and commented, and fixed a number of bugs.
* Simplifying and fixing further.
* Improved performance for skipping large amounts of files.
* Added in extra checks, and changed paths. We should probably unify these path styles.
* Fixed stutter.
* Removed extraneous functions.
* Cleaned up more, added more testing; dealt with multiple sequential events correctly.
Removed dmon, and replaced with logic that works across Linux, Mac, FreeBSD and Windows. Have tested on all platforms, and seems to work.
Co-authored-by: Jan200101 <sentrycraft123@gmail.com>
Before, syntax patterns/regexes that started with `^` didn't have the
desired effect of matching with the start of the line.
Now those patterns are used only when matching the whole line.
* Items are now objects that can be retrieved and manipulated.
* clip rect is used for left and right panes
* initial support for items to do their own custom drawing by also
doing a clip rect for them
* a custom background color can be specified for the item.
* a command or function can be executed on item click.
* Introduced functionality to easily hide or show all or specific items.
* Better handling of deprecated get_items()
* Spacing is automatically added to items and cleaned on deprecated
items.
* Default items where separated and given the names:
doc:file, doc:position, doc:indentation, doc:lines,
doc:line-ending, core.commandview.
* Some default right or left click actions where given to the default
items.
* Started adding required bits to support dragging to left and right
panes when some items aren't visible.
Note: should work well enough already but maybe some repetitive stuff can be
cleaned out.
* Support for predicates by introducing add_item().
* Support for performing click actions on items.
* Support for optional tooltips on item hover.
* Deprecate the usage of get_item().
* Fixed rendering computations for y offset.
* Force monospacing if every ascii character has the same integer advance.
* Added in explanatory comment.
* Fixed issues.
* Made lines less long.
The pattern cannot be tested in advance as it seems that Lua inspect
the pattern only partially, the part that is actually used.
We resort to use pcall to catch any error when using the pattern.
This is needed for example when a selection has both `line1` and `col1`
at 1, and the left arrow is pressed: `line2` and `col2` change, while
`line1` and `col1` don't, but we still want to scroll.
Evolve the rule for directory in ignore_files to be more natural
and easy to understand.
When a final '/' or '/$' is found we consider the pattern to match
a directory and the pattern is not modifed. In turns, is used, before
matching a directory's name a final '/' is appended to its name
before checking if it matches the pattern.
With the previous rule a final '/' in the pattern meant also a directory
but the '/' was removed from the pattern.
When a user's or project's module configuration file is changed we
make sure that the config.plugins fields are all restored so that
all plugins already loaded can continue to work.
Some asserts are placed in case that can effectively occur
so we remove the assertion and we return false. In turn we
adapt the logic accordingly so when false is returned to add
a watch we do not open that directory.
Works correctly and the logic seems sound even if somewhat quirky.
`^%.` match any file of directory whose basename begins with a dot.
`^/node_modules$/"` match a directory named `node_modules` at the project's root.
Note that the final '/' needs to be at the end. The '/' after the '^' needs to be there to trigger
a match of the full path filename so we are sure it is at the root.
PROBLEM: the '/' to trigger full path match could be in a pattern's special expression like:
[^/]
`^%.git$/` match any directory name '.git' anywhere in the project.
`^/%.git$/` match a directory named '.git' only at the project's root.
`^/subprojects/.+/` match any directory in a top-level folder named "subprojects".
`^/build/` match any top level directory whose name begins with "build"
PROBLEM: may be surprising, one may expects it matches only a directory named 'build'. It actually acts like
it was `^/build.*/`.
When changing or opening a project directory do not
take the selected item from suggestion but simply the
entered text as it is.
Otherwise the user may be unable to choose a directory
if the text matches the beginning of suggestion.
Close#791
For special file types like the ones in /dev/ the info
entry's type is neither file neither dir.
We prevent these kind of files from being listed in the
project.
Attempt to fix issue #791.
The logic set with the previous commit for suggest_directory
is similar to the one we use except the previous expression
was false do to operator precedence for "and" versus "or".
With the modification here, when opening a project directory,
we suggest the recently used projects
if the text is equal to dirname(project_dir) + "/" which
happens to be the text the command view is initially set to.
In addition we do the same if text is "". If the condition is
not met we return the suggestions from common.dir_path_suggest to
match the text entered.
Works well on Linux but may not solve the problem on Windows, it
should be tested.
Avoid reloading the core.keymap module when user's config
or project module change.
The reason is the plugins like autocomplete can add keymaps
and the additions from plugins would be lost.
Close issue #793
This reverts commit 0f1b84040d.
The new mechanism to save config.plugins upon user's configuration
reload let us stay compatible with existing plugins.
There was a double error because the config.ignore_files was
used at two differect places in different ways.
Now we apply coherently the original rule to apply
config.ignore_files to the basename of each file or directory.
It wasn't fine to call core.open_doc without filename argument
and later call Doc:save without providing both the filename and
the absolute filename. It was giving a Doc in an inconsistent
status where self.filename was set but not self.abs_filename.
Added an asset to detect early the problem if ever happens again.
In turn the problem prevented the project's module hook to work if the
file was newly created.
Simplifies and uniformize the logic on the Lua side for the
setting of directories' watches. Now we always use the methods:
systems.watch_dir_add / rm
on all the project's directories at any depth when we are not
in files limit mode.
In files limited mode the functions systems.watch_dir_add/rm are
called only on the expanded folders. The shown_subdir table is also
updated only in files limited mode.
On the C side, using the dmon library, we remove the recursive argument
from the system.watch_dir and we always call it recursively except on
Linux. At the same time the functions:
systems.watch_dir_add / rm
are provided but as dummy functions that does nothing except on Linux
where they work as before to add / remove sub-directories in the inotify
watch.
In this was on the Lua side we always act we if the watches needed to be
set for each sub-directory explicitly, independently of the system.
The important improvement introduced is that we always avoid calling
dmon_watch recursively on Linux. This latter thing is problematic with
inotify and is therefore avoided on Linux.
On the other side we simplifies the logic on the Lua side and remove
conditions based on the OS used.
The NagView takes some actual space in the Y and when it appears
it cause the documents' content to be displaced.
The movement of the documents' content is annoying and should be
avoided so we draw the NagView entirely in overlay mode using defer
draw and we always keep its y size to zero to don't affect the
other application contents.
Changes in project's module required an application restart to work.
Now the project will be re-scanned when the project's module changes.
In addition ensure borderless window config is changed when changed
in user's preferences.
It is not a good practice to keep a reference to the project's
directory object outside of the "core" module itself.
The TreeView was using such a reference in the cache item for each
file or directory entry. Replace the reference to the object with
the absolute name of the project directory.
Address issue:
https://github.com/lite-xl/lite-xl/issues/689
Attempt to provide a more accurate fix to commit:
59f64088e1
For this latter what happens is that any change inside a directory
cause the corresponding entry to be folded in the TreeView.
The new change is more accurate because we remove only the stale
entry corresponding to the delete event and we do not reset the
cache of the parent directory using the modify event.
Fix a conspicuous omission to call the dmon_unwatch function
when changing project directory.
This uncovered a bug or a quirk of the dmon library where the watch_ids
can change as a result of calling dmon_unwatch because they are just
indexes on a contiguous array. Use a workaround to always unwatch the
first valid watch_id N times.
Address issue:
https://github.com/lite-xl/lite-xl/issues/689
Attempt to provide a more accurate fix to commit:
59f64088e1
For this latter what happens is that any change inside a directory
cause the corresponding entry to be folded in the TreeView.
The new change is more accurate because we remove only the stale
entry corresponding to the delete event and we do not reset the
cache of the parent directory using the modify event.
The function "file_search" in core.init was sometimes giving a wrong index
value, off by one.
The problem happened for example when the entry to search was "less than"
the first entry, the function returned a value of two instead of one as
expected.
The bug was easily observed creating a new directory with a name that comes
as the first in alphabetical order within the project.