Giter VIP home page Giter VIP logo

ouroboros.nvim's People

Contributors

dundargoc avatar jakemason avatar sampie159 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ouroboros.nvim's Issues

Incorrect switching with identical files in different directories

Hi
I have a project that contains in two different folders, the same files.
The plugin does not switch correctly between *.h and *.cpp if another file was opened earlier.
For example

folder1/rtsp.h
folder1/rtsp.cpp

folder2/rtsp.h
folder2/rtsp.cpp

If I open folder1/rtsp.h then switch to folder1/rtsp.cpp (:Ouroboros) it works correctly, then I open folder2/rtsp.h and try to switch (:Ouroboros), the switch will be to the earlier opened buffer ( folder1/rtsp.cpp).

Create file if not exists

It would be nice if you were asked to create a file/open an empty buffer if the header file can't be found.
What do you think? Does that make sense? Thanks!

consider using tables to match the file extention

using tables to store valid extensions and their corresponding alternates may be easier to scale and require less changes into the code to add new options

if((extension ~= "cpp") and (extension ~= "hpp") and
   (extension ~= "c") and (extension ~= "h") and
   (extension ~= "cc")) then
    utils.log("Ouroboros doesn't work on a file ending in: ." .. extension .. ". Aborting.")
       return
end

if(extension == "cpp" or extension == "hpp") then
    desired_extension = utils.ternary(extension == "cpp", "hpp", "cpp") 
elseif(extension == "c" or extension == "h") then
    desired_extension = utils.ternary(extension == "c", "h", "c")
elseif(extension == "cc") then
    desired_extension = "h"
end       

-- vs

local extensions = {}
local c_cpp_exts_list = {
  cpp = {
    sources = {'cpp', 'C', 'cxx'},
    header = {'hpp', 'hxx'},
  },
  c = {
    sources = {'c', 'cc'},
    headers = {'h'},
  },
}

for ft, exts in pairs(c_cpp_exts) do
  for _, i in ipairs(exts.sources) do
    extentions[i] = exts.headers
  end
  for _, i in ipairs(exts.headers) do
    extentions[i] = exts.sources
  end
end

if not extensions[extension] then
    utils.log("Ouroboros doesn't work on a file ending in: ." .. extension .. ". Aborting.")
    return
end

desired_extension = extensions[extension]

This may even help to extend support to other languages that also have header/implementation structures like Objective-C/Objective-C++

Make switching smarter after split/vsplit.

Currently if you open in a split, and choose to keep that around, Ouroboros can't help you anymore. You'd have to manually navigate your open buffers.

It would be nice if you add a command which:

  • Searches through open buffer.
  • If a matching .h/.c/etc... is found, switch to that buffer.
  • Otherwise, just do the current :Ouroboros does.

So basically if I already have a split open with my corresponding header/source, it'll switch to that.

opening in a split plane?

Hi,
Thank you for building this. Is there any way to open the .h/.cc file in a split plane, instead of having a buffer be opened on top? Thanks!

Remove ./ if in same directory

It would look a bit cleaner if the file path of the second file was displayed in the same path format as the first one.
What I mean is that when I open a few files nvim -O {a,b,c}.hpp their paths in the status bar are displayed simply as a.hpp, while the belonging cpp file's path gets displayed as ./a.cpp.

My mapping is this:
vim.keymap.set('n', '<C-h>', ':Ouroboros<CR>', { silent = true })

Error when trying to create file

Hey

Trying to create a file, I am getting an error thrown that reads:

Error: E5108: Error executing lua Vim:E739: Cannot create directory /XXXXXXXXXX/cppcache/src: file already exists
stack traceback:
	[C]: in function 'mkdir'
	.../.local/share/nvim/lazy/ouroboros/lua/ouroboros/init.lua:86: in function 'on_confirm'
	/usr/share/nvim/runtime/lua/vim/ui.lua:103: in function 'input'
	.../.local/share/nvim/lazy/ouroboros/lua/ouroboros/init.lua:81: in function 'switch'
	[string ":lua"]:1: in main chunk

I noticed in the switch function, you have an extra - I think vim.fn.mkdir(path, "-p")

In the neovim docs they do not https://neovim.io/doc/user/builtin.html#E739

ftplugin can be improve

if exists("g:loaded_ouroboros")
    finish
endif
let g:loaded_ouroboros = 1

ftplugins are source every time a corresponding filetype it is useful to set local options or local commands having a global control variable prevents this.

command! -buffer -nargs=0 Ouroboros lua ouroboros.list()

commands should be enable in their corresponding scopes, global if they works across multiple buffers or local if they are expected to work only in the local buffer

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.