mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 00:21:15 +01:00
Fix: nvim command with a directory path passed to it works now
This commit is contained in:
21
init.lua
21
init.lua
@@ -1,6 +1,10 @@
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- Disable netrw
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-- keymaps.lua
|
||||
require 'keymaps'
|
||||
|
||||
@@ -335,6 +339,23 @@ vim.o.softtabstop = 0 -- number of spaces per Tab in insert mode
|
||||
vim.o.tabstop = 4 -- number of spaces a Tab counts for
|
||||
vim.o.smartindent = true -- auto-indent new lines
|
||||
|
||||
-- [[ Change current directory to the path if specified and open Neo-tree there ]]
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
callback = function(data)
|
||||
local is_directory = vim.fn.isdirectory(data.file) == 1
|
||||
if not is_directory then
|
||||
return
|
||||
end
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if vim.api.nvim_buf_get_name(buf) == '' and vim.api.nvim_buf_line_count(buf) == 1 then
|
||||
vim.api.nvim_buf_delete(buf, { force = true })
|
||||
end
|
||||
vim.defer_fn(function()
|
||||
require('neo-tree.command').execute { action = 'show', dir = data.file }
|
||||
end, 50)
|
||||
end,
|
||||
})
|
||||
|
||||
-- [[ Highlight on yank ]]
|
||||
-- See `:help vim.highlight.on_yank()`
|
||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||
|
||||
@@ -21,6 +21,12 @@ local function should_skip(buf)
|
||||
return true
|
||||
end
|
||||
|
||||
-- Skip directories if spefified with the nvim command
|
||||
local stat = vim.loop.fs_stat(bufname)
|
||||
if stat and stat.type == 'directory' then
|
||||
return true
|
||||
end
|
||||
|
||||
-- Skip known plugin filetypes
|
||||
for _, v in ipairs(skip_buffers) do
|
||||
if ft == v or bufname:match(v) then
|
||||
@@ -36,6 +42,7 @@ local function rename_deleted_buffers()
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_valid(buf) and not should_skip(buf) then
|
||||
local bufname = vim.api.nvim_buf_get_name(buf)
|
||||
|
||||
if bufname ~= '' and vim.fn.filereadable(bufname) == 0 then
|
||||
-- Skip buffers for files that have never been written (new files)
|
||||
local ftime = vim.fn.getftime(bufname)
|
||||
|
||||
Reference in New Issue
Block a user