Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Use OS independent separators
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 13, 2021
1 parent e6b97e1 commit 2cfda5e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ Also the corresponding Lua functions with the same names as the arguments are av
To configure the plugin, you can call `require('cmake').setup(values)`, where `values` is a dictionary with the parameters you want to override. Here are the defaults:

```lua
local Path = require('plenary.path')
require('cmake').setup({
parameters_file = 'neovim.json', -- JSON file to store information about selected target, run arguments and build type.
build_dir = '{cwd}/build/{os}-{build_type}', -- Build directory. The expressions `{cwd}`, `{os}` and `{build_type}` will be expanded with the corresponding text values.
build_dir = Path:new('{cwd}', 'build', '{os}-{build_type}'), -- Build directory. The expressions `{cwd}`, `{os}` and `{build_type}` will be expanded with the corresponding text values.
samples_path = script_path:parent():parent():parent() / 'samples', -- Folder with samples. `samples` folder from the plugin directory is used by default.
default_projects_path = '~/Projects', -- Default folder for creating project.
default_projects_path = Path:new(vim.loop.os_homedir(), 'Projects'), -- Default folder for creating project.
configure_arguments = '-D CMAKE_EXPORT_COMPILE_COMMANDS=1', -- Default arguments that will be always passed at cmake configure step. By default tells cmake to generate `compile_commands.json`.
build_arguments = '', -- Default arguments that will be always passed at cmake build step.
asyncrun_options = { save = 2 }, -- AsyncRun options that will be passed on cmake execution. See https://github.com/skywind3000/asyncrun.vim#manual
Expand Down
4 changes: 2 additions & 2 deletions lua/cmake/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local script_path = Path:new(debug.getinfo(1).source:sub(2))
local config = {
defaults = {
parameters_file = 'neovim.json',
build_dir = '{cwd}/build/{os}-{build_type}',
build_dir = Path:new('{cwd}', 'build', '{os}-{build_type}'),
samples_path = script_path:parent():parent():parent() / 'samples',
default_projects_path = '~/Projects',
default_projects_path = Path:new(vim.loop.os_homedir(), 'Projects'),
configure_arguments = '-D CMAKE_EXPORT_COMPILE_COMMANDS=1',
build_arguments = '',
asyncrun_options = { save = 2 },
Expand Down
6 changes: 3 additions & 3 deletions lua/cmake/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ function utils.get_build_dir(parameters)
parameters = utils.get_parameters()
end

local build_dir = config.build_dir
local build_dir = tostring(config.build_dir)
build_dir = build_dir:gsub('{cwd}', vim.fn.getcwd())
build_dir = build_dir:gsub('{os}', os)
build_dir = build_dir:gsub('{build_type}', parameters['buildType']:lower())
return Path:new(build_dir)
end

function utils.get_reply_dir(build_dir)
return build_dir / '.cmake/api/v1/reply'
return build_dir / '.cmake' / 'api' / 'v1' / 'reply'
end

function utils.get_codemodel_targets(reply_dir)
Expand All @@ -49,7 +49,7 @@ end

-- Tell CMake to generate codemodel
function utils.make_query_files(build_dir)
local query_dir = build_dir / '.cmake/api/v1/query'
local query_dir = build_dir / '.cmake' / 'api' / 'v1' / 'query'
if not query_dir:mkdir({ parents = true }) then
utils.notify('Unable to create folder ' .. query_dir.filename, vim.log.levels.ERROR)
return false
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ local function create_project(opts)
return
end

local project_location = vim.fn.input('Create in: ', Path:new(config.default_projects_path):expand(), 'file')
local project_location = vim.fn.input('Create in: ', tostring(config.default_projects_path), 'file')
if #project_location == 0 then
utils.notify('Project path cannot be empty', vim.log.levels.ERROR)
return
Expand Down

0 comments on commit 2cfda5e

Please sign in to comment.