Coder Social home page Coder Social logo

Comments (17)

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024 1

@rohit-kumar-j I am using mingw, at the moment, so no idea if it works or not.
@Civitasv Nope, I played a bit with Windows policies, but also no luck (Windows 11).

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

This plugin use symlink to achieve that, why not use .clangd?

from cmake-tools.nvim.

ayles avatar ayles commented on July 17, 2024

But switches between release types are initiated by plugin. It is inconvenient to change path to compilation database every time by hand

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

Make sense, I will see how i can implement it.

from cmake-tools.nvim.

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024

Something like this in init.lua:125, inside on_success function after running the CMake command. What I can't figure out how to delete the file when exiting the editor.

local compile_commands = config.build_directory.filename .. "/compile_commands.json"
local cmd = "[ -e " .. compile_commands .. " ] && cp " .. compile_commands .. " ."

local handle = io.popen(cmd)
handle:close()

from cmake-tools.nvim.

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024

Platform independent solution.

diff --git a/lua/cmake-tools/init.lua b/lua/cmake-tools/init.lua
index 7293c22..6cf7518 100644
--- a/lua/cmake-tools/init.lua
+++ b/lua/cmake-tools/init.lua
@@ -127,6 +127,13 @@ function cmake.generate(opt, callback)
       if type(callback) == "function" then
         callback()
       end
+
+      local infile  = io.open(config.build_directory.filename .. "/compile_commands.json", "r")
+      local outfile = io.open("compile_commands.json", "w")
+
+      outfile:write(infile:read("*a"))
+      outfile:close()
+      infile:close()
     end,
     cmake_console_position = const.cmake_console_position,
     cmake_show_console = const.cmake_show_console,

from cmake-tools.nvim.

ayles avatar ayles commented on July 17, 2024

Is there any reason to copy it instead of just making symlink?

from cmake-tools.nvim.

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024

@ayles Because it should be platform independent and I haven't seen anything in the LUA file api that allows to create symbolic links. On Linux you would use ln -s and on Windows mklink.

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

@iFuSiiOnzZ Why not use vim.cmd("term ln -s")?

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

I've added this ability. See 6e4e422

from cmake-tools.nvim.

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024

Haven't test in on Linux yet. On Windows there are a some problems.

Powershell normal user

CMake Error: failed to create symbolic link 'C:\Users\Develop\Projects\ls/compile_commands.json': A required privilege is not held by the client.

Powershell with admin privileges

:!cmake -E create_symlink cmake_build_Debug/compile_commands.json C:\Users\AndreiAJ\Projects\ls/compile_commands.json

from cmake-tools.nvim.

rohit-kumar-j avatar rohit-kumar-j commented on July 17, 2024

@iFuSiiOnzZ, I did you try compile_commands with MSVC on powershell?

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

Powershell with admin privileges

When in admin privileges, Was the command successful?

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

Can you show the error messages?

from cmake-tools.nvim.

iFuSiiOnzZ avatar iFuSiiOnzZ commented on July 17, 2024

For some reason the neovim log is empty and cmake reports nothing about the error.
What is more strange... I ran cmake -E create_symlink from the terminal and it worked.

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

That's interesting.

from cmake-tools.nvim.

Civitasv avatar Civitasv commented on July 17, 2024

Look at this.

from cmake-tools.nvim.

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.