"Demo" init file
Have you checked for existing feature requests?
- [X] Completed
Summary
Hacking the init script is a bit daunting if a user doesn't know both Javascript and some of the Pulsar specific stuff.
I'm thinking it would be a good idea if we could make a much more detailed commented out init script that can show off some of the more interesting things that you can do with Pulsar and play around with to really show off the hackability side of it.
We could also provide links to the relevant Pulsar docs within it.
Enter your response below:
Highlights Pulsar's "hyper-hackable" USP by lowering the barrier for entry and providing a demo of what kinds of things can be done.
Any alternatives?
A docs section with tutorial, example init files or a community wiki with demonstrations.
Other examples:
Lite-XL has an init.lua:
-- put user settings here
-- this module will be loaded after everything else when the application starts
-- it will be automatically reloaded when saved
local core = require "core"
local keymap = require "core.keymap"
local config = require "core.config"
local style = require "core.style"
------------------------------ Themes ----------------------------------------
-- light theme:
-- core.reload_module("colors.summer")
--------------------------- Key bindings -------------------------------------
-- key binding:
-- keymap.add { ["ctrl+escape"] = "core:quit" }
------------------------------- Fonts ----------------------------------------
-- customize fonts:
style.font = renderer.font.load(DATADIR .. "/fonts/FiraSans-Regular.ttf", 12 * SCALE)
-- style.code_font = renderer.font.load(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", 14 * SCALE)
--
-- DATADIR is the location of the installed Lite XL Lua code, default color
-- schemes and fonts.
-- USERDIR is the location of the Lite XL configuration directory.
--
-- font names used by lite:
-- style.font : user interface
-- style.big_font : big text in welcome screen
-- style.icon_font : icons
-- style.icon_big_font : toolbar icons
-- style.code_font : code
--
-- the function to load the font accept a 3rd optional argument like:
--
-- {antialiasing="grayscale", hinting="full", bold=true, italic=true, underline=true, smoothing=true, strikethrough=true}
--
-- possible values are:
-- antialiasing: grayscale, subpixel
-- hinting: none, slight, full
-- bold: true, false
-- italic: true, false
-- underline: true, false
-- smoothing: true, false
-- strikethrough: true, false
------------------------------ Plugins ----------------------------------------
-- enable or disable plugin loading setting config entries:
-- enable plugins.trimwhitespace, otherwise it is disable by default:
-- config.plugins.trimwhitespace = true
--
-- disable detectindent, otherwise it is enabled by default
-- config.plugins.detectindent = false
---------------------------- Miscellanous --------------------------------------
-- modify list of files to ignore when indexing the project:
-- config.ignore_files = {
-- -- folders
-- "^%.svn/", "^%.git/", "^%.hg/", "^CVS/", "^%.Trash/", "^%.Trash%-.*/",
-- "^node_modules/", "^%.cache/", "^__pycache__/",
-- -- files
-- "%.pyc$", "%.pyo$", "%.exe$", "%.dll$", "%.obj$", "%.o$",
-- "%.a$", "%.lib$", "%.so$", "%.dylib$", "%.ncb$", "%.sdf$",
-- "%.suo$", "%.pdb$", "%.idb$", "%.class$", "%.psd$", "%.db$",
-- "^desktop%.ini$", "^%.DS_Store$", "^%.directory$",
-- }
Some window managers and other non-text editor applications have similar commented config files, such as the Kitty terminal kitty.conf file.
Does anyone have some useful snippets in their init file that we can show off here?
I decaff'd the example for the init file from the docs. It isn't the neatest example, pretty much just taken from a coffeescript conversion but it does work.
Because
init.coffeeprovides access to Atom's API, you can use it to implement useful commands without creating a new package or extending an existing one. Here's a command which uses the Selection API and Clipboard API to construct a Markdown link from the selected text and the clipboard contents as the URL:
atom.commands.add('atom-text-editor', 'markdown:paste-as-link', () => {
let clipboardText, editor, selection;
if (!(editor = atom.workspace.getActiveTextEditor())) {
return;
}
selection = editor.getLastSelection();
clipboardText = atom.clipboard.read();
return selection.insertText("[" + (selection.getText()) + "](" + clipboardText + ")");
});