@@ -83,6 +83,39 @@ I hope you enjoy your Neovim journey,
8383
8484P.S. You can delete this when you're done too. It's your config now! :)
8585--]]
86+ --
87+ --
88+ -- One last note before we leave you to play around: Lua is a real programming language.
89+ -- Why is that important? First of all, that you can use all the features of Lua,
90+ -- like variables, conditionals, loops and functions. Secondly, that you can interact with
91+ -- neovim in concise way. The following lines contain two examples that might give you some inspirations.
92+ -- This snippet adds a keymap to open a predefined file in a new tab:
93+ -- local function open_notes()
94+ -- vim.cmd 'tabnew'
95+ -- vim.cmd 'tabnext'
96+ -- local command = 'e' .. '/full_path/to_file' -- '..' is the build in string concatenation
97+ -- vim.cmd(command)
98+ -- end
99+ -- vim.keymap.set('n', '<leader>m', open_notes)
100+ --
101+ -- This is interesting because there are certainly plugins out there
102+ -- that provide this functionallity in a sophisticated manner.
103+ -- But a plugin might change, might not provide the options you like,
104+ -- or you might not use this feature at all. If you do not use it,
105+ -- simply delete this code and you are done. If you like it, you
106+ -- may expand to what you need and nothing else. And if this is to
107+ -- much work, you might end up using the plugin anyway, but based
108+ -- on valid effidence that you like this feature.
109+ --
110+ -- The following snippet loads/executes some lua file when a specific file is opened:
111+ -- if vim.fn.expand("%") == "file.txt" then
112+ -- vim.cmd("so ./additional_config.lua")
113+ -- end
114+ -- One use-case could be a journal where the script.lua automatically moves your cursor
115+ -- to the end of file and inserts the curent date when you open it. (This suggestion is certainly not
116+ -- the easiest example, but that it is possible at all should get your mind racing
117+ -- with possibilities.)
118+ -- Good luck tinkering :)
86119
87120-- Set <space> as the leader key
88121-- See `:help mapleader`
0 commit comments