simrat39 / symbols-outline.nvim

A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.
MIT License
1.85k stars 97 forks source link

Wrong previewing location #221

Open TroySigX opened 1 year ago

TroySigX commented 1 year ago

I have the following cpp file:

#include <bits/stdc++.h>

using namespace std;

namespace IO{
    void setIn(string s) {freopen(s.c_str(), "r", stdin);}
    void setOut(string s) {freopen(s.c_str(), "w", stdout);}
    void setIO(string s = ""){
        ios_base::sync_with_stdio(false);
        cin.tie(0); cout.tie(0);
        if (s != ""){
            setIn(s + ".in");
            setOut(s + ".out");
        }
    }
}

using namespace IO;

namespace Function{
    template <typename T> T amx(T x){
        return x;
    }
    template <class T, class... Ts> T amx(T t, Ts... ts){
        return max(t, amx(ts...));
    }
    template <typename T> T amn(T x){
        return x;
    }
    template <class T, class... Ts> T amn(T t, Ts... ts){
        return min(t, amn(ts...));
    }
    template <class T, class... Ts> bool amax(T &a, Ts... b){
        T x = amx(b...);
        if (a < x){
            a = x;
            return 1;
        }
        return 0;
    }
    template <class T, class... Ts> bool amin(T &a, Ts... b){
        T x = amn(b...);
        if (a > x){
            a = x;
            return 1;
        }
        return 0;
    }
    template <typename T> void compress(T &a){
        sort(a.begin(), a.end());
        a.resize(unique(a.begin(), a.end()) - a.begin());
    }
    template <typename T> long long sqr(T x) {return 1LL * x * x;}
    template <typename T1, typename T2> long long GCD(T1 a, T2 b) {return b == 0 ? a : GCD(b, a % b);}
    template <typename T1, typename T2> long long LCM(T1 a, T2 b) {return 1LL * a / GCD(a, b) * b;}
}

using namespace Function;

namespace Output{
    string End_Of_Stream = "\n";
    void print(int x) {cout << x << End_Of_Stream;}
    void print(unsigned int x) {cout << x << End_Of_Stream;}
    void print(long unsigned int x) {cout << x << End_Of_Stream;}
    void print(long long x) {cout << x << End_Of_Stream;}
    void print(unsigned long long x) {cout << x << End_Of_Stream;}
    void print(float x) {cout << x << End_Of_Stream;}
    void print(double x) {cout << x << End_Of_Stream;}
    void print(long double x) {cout << x << End_Of_Stream;}
    void print(char x) {cout << x << End_Of_Stream;}
    void print(const char* x) {cout << x << End_Of_Stream;}
    void print(string x = "") {cout << x << End_Of_Stream;}
    void print(bool x) {cout << x << End_Of_Stream;}

    template <typename T1, typename T2> void print(pair <T1, T2> a) {cout << a.first << " " << a.second << End_Of_Stream;}
    template <size_t sz> void print(bitset<sz> a) {
        for(int i = 0; i < sz; i++){
            cout << a[i];
        }
        cout << End_Of_Stream;
    }

    template <typename T> void write(T x) {print(x);}

    template <class T, class... Ts> void write(T t, Ts... ts){
        write(t);
        write(ts...);
    }

    template <class T, class... Ts> void print(T t, Ts... ts){
        End_Of_Stream = " ";
        write(t, ts...);
        End_Of_Stream = "\n";
        print();
    }

    template <typename T> void print(T a){
        for(auto it : a){
            print(it);
        }
    }

    template <class T, class... Ts> void prine(T t, Ts... ts){
        print(t, ts...);
        exit(0);
    }
}

using namespace Output;

typedef pair <int, int> pii;

const long long INFL = 1e18 + 1e15;
const int INF = 1e9 + 10;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;

int main(){
    setIO();

    return 0;
}

Open outline with auto_preview and expanded, when previewing Function (7-th line in ouline list), the preview window navigates to Output, which is wrong. The issue doesn't only happen to cpp files, but also to typescript files and possibly more filetypes.

Djedouas commented 8 months ago

same with python file. the preview is wrong (with K), but the "hover current symbol" is correct (with Ctrl+Space)

hedyhli commented 8 months ago

@Djedouas @TroySigX What providers are you using? It works well for me using either LSP or markdown.

Djedouas commented 8 months ago

@hedyhli I'm new to neovim, what do you mean by "provider"?

Djedouas commented 8 months ago

I wonder if my problem is https://github.com/simrat39/symbols-outline.nvim/issues/176 in fact

Djedouas commented 8 months ago

@hedyhli with LunarVim, I guess the provider is LSP (I chose jedi-language-server)

Djedouas commented 8 months ago

but it may be treesitter

hedyhli commented 8 months ago

what do you mean by "provider"?

symbols-outline supports a few "backends"/"providers" -- where those symbols in the outline come from. It's either CoC or LSP at the moment (unless you're editing a markdown file, then it's markdown).

I guess the provider is LSP

Alright 👍, then if not for #176, the live-previewing should work as expected.

Speaking of which, since simrat39 is not responding to PRs and issues at the moment, feel free to try out my fork in the meantime. I fixed the preview issue there and also along with many other issues. Details of all the new features and the bug fixes are listed in the readme.

If you want to switch to my fork you have to change the plugin spec from "simrat39/symbols-outline.nvim" to "hedyhli/symbols-outline.nvim".