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

Commit

Permalink
Fix CMake project creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Nov 23, 2021
1 parent eb5ebde commit b5c7565
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ To configure the plugin, you can call `require('cmake').setup(values)`, where `v
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 = 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 = Path:new(vim.loop.os_homedir(), 'Projects'), -- Default folder for creating project.
build_dir = tostring(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 = tostring(script_path:parent():parent():parent() / 'samples'), -- Folder with samples. `samples` folder from the plugin directory is used by default.
default_projects_path = tostring(Path:new(vim.loop.os_homedir(), 'Projects')), -- Default folder for creating project.
configure_args = { '-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_args = {}, -- Default arguments that will be always passed at cmake build step.
quickfix_height = 10, -- Height of the opened quickfix.
Expand Down
6 changes: 3 additions & 3 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 = Path:new('{cwd}', 'build', '{os}-{build_type}'),
samples_path = script_path:parent():parent():parent() / 'samples',
default_projects_path = Path:new(vim.loop.os_homedir(), 'Projects'),
build_dir = tostring(Path:new('{cwd}', 'build', '{os}-{build_type}')),
samples_path = tostring(script_path:parent():parent():parent() / 'samples'),
default_projects_path = tostring(Path:new(vim.loop.os_homedir(), 'Projects')),
configure_args = { '-D', 'CMAKE_EXPORT_COMPILE_COMMANDS=1' },
build_args = {},
quickfix_height = 10,
Expand Down
2 changes: 1 addition & 1 deletion lua/cmake/project_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function ProjectConfig:get_build_dir()
return self.build_dir
end

self.build_dir = tostring(config.build_dir)
self.build_dir = config.build_dir
self.build_dir = self.build_dir:gsub('{cwd}', vim.loop.cwd())
self.build_dir = self.build_dir:gsub('{os}', os)
self.build_dir = self.build_dir:gsub('{build_type}', self.json.build_type:lower())
Expand Down
4 changes: 2 additions & 2 deletions lua/telescope/_extensions/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ local function create_project(opts)
pickers.new(opts, {
prompt_title = 'Select sample',
finder = finders.new_table({
results = vim.fn.map(scandir.scan_dir(tostring(config.samples_path), { depth = 1, only_dirs = true }), 'fnamemodify(v:val, ":t")'),
results = vim.fn.map(scandir.scan_dir(config.samples_path, { depth = 1, only_dirs = true }), 'fnamemodify(v:val, ":t")'),
}),
sorter = sorters.get_fzy_sorter(),
attach_mappings = function(prompt_bufnr)
Expand All @@ -114,7 +114,7 @@ local function create_project(opts)
return
end

local project_location = vim.fn.input('Create in: ', tostring(config.default_projects_path), 'file')
local project_location = vim.fn.input('Create in: ', 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 b5c7565

Please sign in to comment.