Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/tabnine/binary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local TabnineBinary = {}
local config = require("tabnine.config")

local api_version = "4.4.223"
local binaries_path = utils.script_path() .. "/binaries"
local binaries_path = utils.module_dir() .. "/binaries"

local function arch_and_platform()
local os_uname = uv.os_uname()
Expand Down
2 changes: 1 addition & 1 deletion lua/tabnine/chat/binary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local function binary_name()
end
end

local binary_path = utils.script_path() .. "/../chat/target/release/" .. binary_name()
local binary_path = utils.module_dir() .. "/chat/target/release/" .. binary_name()

function ChatBinary:available()
return vim.fn.executable(binary_path) == 1
Expand Down
4 changes: 2 additions & 2 deletions lua/tabnine/chat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ local get_symbols_request = nil

local M = { enabled = false }

local CHAT_STATE_FILE = utils.script_path() .. "/../chat_state.json"
local CHAT_SETTINGS_FILE = utils.script_path() .. "/../chat_settings.json"
local CHAT_STATE_FILE = utils.module_dir() .. "/chat_state.json"
local CHAT_SETTINGS_FILE = utils.module_dir() .. "/chat_settings.json"

local chat_state = nil
local chat_settings = nil
Expand Down
2 changes: 1 addition & 1 deletion lua/tabnine/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local fn = vim.fn
local utils = require("tabnine.utils")

local M = {}
local DISABLED_FILE = utils.script_path() .. "/.disabled"
local DISABLED_FILE = utils.module_dir() .. "/.disabled"
local config = require("tabnine.config")
local state = require("tabnine.state")
local tabnine_binary = require("tabnine.binary")
Expand Down
13 changes: 11 additions & 2 deletions lua/tabnine/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ function M.subset(tbl, from, to)
return { unpack(tbl, from, to) }
end

function M.script_path()
---returns the directory of the running script
---@return string
function M.script_dir()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)") .. "../.."
return str:match("(.*/)") or "./"
end

---returns the directory of the root of the module
---@return string
function M.module_dir()
-- HACK: This only works if this file is not moved!
return M.script_dir() .. "../.."
end

function M.prequire(...)
Expand Down