mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 10:26:42 +10:00
Merge #36870 from justinmk/luacore
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
--- Adds one or more blank lines above or below the cursor.
|
||||
-- TODO: move to _defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
--- @param above? boolean Place blank line(s) above the cursor
|
||||
local function add_blank(above)
|
||||
local offset = above and 1 or 0
|
||||
local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
|
||||
local linenr = vim.api.nvim_win_get_cursor(0)[1]
|
||||
vim.api.nvim_buf_set_lines(0, linenr - offset, linenr - offset, true, repeated)
|
||||
end
|
||||
|
||||
-- TODO: move to _defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
function M.space_above()
|
||||
add_blank(true)
|
||||
end
|
||||
|
||||
-- TODO: move to _defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
function M.space_below()
|
||||
add_blank()
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,3 +1,5 @@
|
||||
-- Default user-commands, autocmds, mappings, menus.
|
||||
|
||||
--- Default user commands
|
||||
do
|
||||
vim.api.nvim_create_user_command('Inspect', function(cmd)
|
||||
@@ -440,13 +442,13 @@ do
|
||||
-- Add empty lines
|
||||
vim.keymap.set('n', '[<Space>', function()
|
||||
-- TODO: update once it is possible to assign a Lua function to options #25672
|
||||
vim.go.operatorfunc = "v:lua.require'vim._buf'.space_above"
|
||||
vim.go.operatorfunc = "v:lua.require'vim._core.util'.space_above"
|
||||
return 'g@l'
|
||||
end, { expr = true, desc = 'Add empty line above cursor' })
|
||||
|
||||
vim.keymap.set('n', ']<Space>', function()
|
||||
-- TODO: update once it is possible to assign a Lua function to options #25672
|
||||
vim.go.operatorfunc = "v:lua.require'vim._buf'.space_below"
|
||||
vim.go.operatorfunc = "v:lua.require'vim._core.util'.space_below"
|
||||
return 'g@l'
|
||||
end, { expr = true, desc = 'Add empty line below cursor' })
|
||||
end
|
||||
@@ -1,27 +1,5 @@
|
||||
-- Nvim-Lua stdlib: the `vim` module (:help lua-stdlib)
|
||||
--
|
||||
-- Lua code lives in one of four places:
|
||||
-- 1. Plugins! Not everything needs to live on "vim.*". Plugins are the correct model for
|
||||
-- non-essential features which the user may want to disable or replace with a third-party
|
||||
-- plugin. Examples: "editorconfig", "comment".
|
||||
-- - "opt-out": runtime/plugin/*.lua
|
||||
-- - "opt-in": runtime/pack/dist/opt/
|
||||
-- 2. runtime/lua/vim/ (the runtime): Lazy-loaded modules. Examples: `inspect`, `lpeg`.
|
||||
-- 3. runtime/lua/vim/shared.lua: pure Lua functions which always are available. Used in the test
|
||||
-- runner, and worker threads/processes launched from Nvim.
|
||||
-- 4. runtime/lua/vim/_editor.lua: Eager-loaded code which directly interacts with the Nvim
|
||||
-- editor state. Only available in the main thread.
|
||||
--
|
||||
-- The top level "vim.*" namespace is for fundamental Lua and editor features. Use submodules for
|
||||
-- everything else (but avoid excessive "nesting"), or plugins (see above).
|
||||
--
|
||||
-- Compatibility with Vim's `if_lua` is explicitly a non-goal.
|
||||
--
|
||||
-- Reference (#6580):
|
||||
-- - https://github.com/luafun/luafun
|
||||
-- - https://github.com/rxi/lume
|
||||
-- - http://leafo.net/lapis/reference/utilities.html
|
||||
-- - https://github.com/bakpakin/Fennel (pretty print, repl)
|
||||
|
||||
-- These are for loading runtime modules lazily since they aren't available in
|
||||
-- the nvim binary as specified in executor.c
|
||||
@@ -1321,7 +1299,7 @@ function vim.deprecate(name, alternative, version, plugin, backtrace)
|
||||
end
|
||||
end
|
||||
|
||||
require('vim._options')
|
||||
require('vim._core.options')
|
||||
|
||||
--- Remove at Nvim 1.0
|
||||
---@deprecated
|
||||
@@ -1,3 +1,5 @@
|
||||
-- For 'exrc' and related functionality.
|
||||
|
||||
local files = vim.fs.find({ '.nvim.lua', '.nvimrc', '.exrc' }, {
|
||||
type = 'file',
|
||||
upward = true,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
-- For "--listen" and related functionality.
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Called by builtin serverlist(). Returns all running servers in stdpath("run").
|
||||
|
||||
@@ -13,7 +13,7 @@ if has_strbuffer then
|
||||
-- Lua 5.1 does not have __len metamethod so we need to provide a len()
|
||||
-- function to use instead.
|
||||
|
||||
--- @param buf vim._stringbuffer
|
||||
--- @param buf vim._core.stringbuffer
|
||||
--- @return integer
|
||||
function M.len(buf)
|
||||
return #buf
|
||||
@@ -22,7 +22,7 @@ if has_strbuffer then
|
||||
return M
|
||||
end
|
||||
|
||||
--- @class vim._stringbuffer
|
||||
--- @class vim._core.stringbuffer
|
||||
--- @field private buf string[]
|
||||
--- @field package len integer absolute length of the `buf`
|
||||
--- @field package skip_ptr integer
|
||||
@@ -103,7 +103,7 @@ function M.new()
|
||||
return setmetatable({}, StrBuffer):reset()
|
||||
end
|
||||
|
||||
--- @param buf vim._stringbuffer
|
||||
--- @param buf vim._core.stringbuffer
|
||||
function M.len(buf)
|
||||
return buf.len - buf.skip_ptr
|
||||
end
|
||||
@@ -1,5 +1,27 @@
|
||||
-- Nursery for random things that may later find their way into stdlib if they mature.
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Adds one or more blank lines above or below the cursor.
|
||||
-- TODO: move to _core/defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
--- @param above? boolean Place blank line(s) above the cursor
|
||||
local function add_blank(above)
|
||||
local offset = above and 1 or 0
|
||||
local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
|
||||
local linenr = vim.api.nvim_win_get_cursor(0)[1]
|
||||
vim.api.nvim_buf_set_lines(0, linenr - offset, linenr - offset, true, repeated)
|
||||
end
|
||||
|
||||
-- TODO: move to _core/defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
function M.space_above()
|
||||
add_blank(true)
|
||||
end
|
||||
|
||||
-- TODO: move to _core/defaults.lua once it is possible to assign a Lua function to options #25672
|
||||
function M.space_below()
|
||||
add_blank()
|
||||
end
|
||||
|
||||
--- Edit a file in a specific window
|
||||
--- @param winnr number
|
||||
--- @param file string
|
||||
|
||||
@@ -50,7 +50,7 @@ if vim.api then
|
||||
end
|
||||
|
||||
-- builtin functions which always should be available
|
||||
require('vim.shared')
|
||||
require('vim._core.shared')
|
||||
|
||||
vim._submodules = {
|
||||
inspect = true,
|
||||
@@ -95,6 +95,6 @@ end
|
||||
|
||||
-- only on main thread: functions for interacting with editor state
|
||||
if vim.api and not vim.is_thread() then
|
||||
require('vim._editor')
|
||||
require('vim._system')
|
||||
require('vim._core.editor')
|
||||
require('vim._core.system')
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local log = require('vim.lsp.log')
|
||||
local protocol = require('vim.lsp.protocol')
|
||||
local lsp_transport = require('vim.lsp._transport')
|
||||
local strbuffer = require('vim._stringbuffer')
|
||||
local strbuffer = require('vim._core.stringbuffer')
|
||||
local validate, schedule_wrap = vim.validate, vim.schedule_wrap
|
||||
|
||||
--- Embeds the given string into a table and correctly computes `Content-Length`.
|
||||
|
||||
Reference in New Issue
Block a user