Code Monkey home page Code Monkey logo

Comments (8)

jxi24 avatar jxi24 commented on June 12, 2024 1

Sounds reasonable. I will begin working on it.

from neovim-cmake.

Shatur avatar Shatur commented on June 12, 2024

When locally using the code for development, I copy a basic configuration file to the CMAKE_BUILD_DIR instead of copying it to each directory in which a target exists. This then results in the run command not working, since it can't load the configuration file.

Have you considered setting CMAKE_RUNTIME_OUTPUT_DIRECTORY to CMAKE_BUILD_DIR? Since you copying configuration files there.

I would not mind adding an option to specify the startup folder, but at the moment the options are not set on a per-project. So you have to change your running path each time you change the project.

from neovim-cmake.

jxi24 avatar jxi24 commented on June 12, 2024

I have not thought about that, but I would prefer to keep my testsuite executables separate from the main executable. I understand the issue with having to do a different setup per-project. Would it be possible to do something like have a global configuration, about allow a local file maybe something like .neovim-cmake.cfg override the default settings? This way one could have project specific commands if desired, but wouldn't mess with the global setup.

from neovim-cmake.

Shatur avatar Shatur commented on June 12, 2024

Hm... Okay! We currently have neovim.json file that contains run arguments and selected project.
Perhaps we could expand it to store more settings. As startup directory or cmake options. But this will require some work :)
I can do this later when I have a little free time.
But if you want to contribute - please, let me know, we could discuss implementation details.

from neovim-cmake.

jxi24 avatar jxi24 commented on June 12, 2024

I wouldn't mind contributing to the project. I would be happy to discuss implementation details.

from neovim-cmake.

Shatur avatar Shatur commented on June 12, 2024

Okay!

For now we have set of options here:

let g:cmake_build_dir = get(g:, 'cmake_build_dir', '{cwd}/build/{os}-{build_type}')
let g:cmake_samples_path = get(g:, 'cmake_samples_path', expand('<sfile>:p:h:h') .. '/samples/')
let g:default_cmake_projects_path = get(g:, 'default_cmake_projects_path', expand('~/Projects'))
let g:cmake_configure_arguments = get(g:, 'cmake_configure_arguments', '-D CMAKE_EXPORT_COMPILE_COMMANDS=1')
let g:cmake_asyncrun_options = get(g:, 'cmake_asyncrun_options', {'save': 2})
let g:cmake_target_asyncrun_options = get(g:, 'cmake_target_asyncrun_options', {})

But some of them could be platform-specific. So I would wrap all settings in neovim.json (including current settings such as selected project or parameters) in a top-level dictionary that contains os name. You could get os name from this variable:

local os = require('ffi').os:lower()

And every time you trying to get setting - just read it from JSON, here is the function to get it content:

function utils.get_parameters()

And set:

function utils.set_parameters(parameters)

If requested setting doesn't exists - use according global setting. I would wrap this into a convenient class (table) and move into a separate file.

Also we should add the option that your requested. I think that it should be local-only. You should check for it here:

function cmake.debug(...)

And here:

function cmake.run(...)

Your thoughts? Suggestions?

from neovim-cmake.

jxi24 avatar jxi24 commented on June 12, 2024

I think the first part makes sense. I would suggest modifying the get_parameters function and the set_parameters function. To first check to see if there is a neovim.json file in the project root directory. If there is, then it should load the parameters from there. If any required settings are missing, then it should load it from the global neovim.json or from the default values.

We would then just have to modify:

local target_dir = vim.fn.fnamemodify(target, ':h')

To see if the user has the option set for a different run directory in the neovim.json file. If they have it set, then use that, otherwise use the current setup. I think that would be cleaner than doing it in both:

function cmake.debug(...)

and here:
function cmake.run(...)

Since both call utils.get_current_target(...)

Does that seem like a reasonable approach?

from neovim-cmake.

Shatur avatar Shatur commented on June 12, 2024

I agree! Just one thing:

If any required settings are missing, then it should load it from the global neovim.json or from the default values.

I would avoid using a global neovim.json. I think that having a project-specific neovim.json and default values is enough.

from neovim-cmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.