forked from Archives/navigator.lua
lsp_signature setup was not documented in README. Add playground folder
parent
4144024068
commit
bad19ebc84
@ -0,0 +1,31 @@
|
||||
# Sandbox/Tutorial
|
||||
|
||||
## introduction
|
||||
|
||||
The folder contains `init.lua`, whitch is a minium vimrc to setup following plugins. Those plugin are some of the
|
||||
most used plugins for programmer.
|
||||
|
||||
- lspconfig
|
||||
- treesitter
|
||||
- navigator
|
||||
- nvim-cmp
|
||||
- luasnip
|
||||
- aurora (colorscheme used in the screenshot)
|
||||
|
||||
There also three folder `js`, `go`, `py`. Those folder have some basic source code you can play with.
|
||||
|
||||
## run init.lua
|
||||
|
||||
```bash
|
||||
cd py
|
||||
neovim -u init.lua
|
||||
```
|
||||
|
||||
Move your cursor around and try to
|
||||
|
||||
- Edit the code
|
||||
- Check symbol reference with `<esc>gr`
|
||||
- Check document symbol with `<esc>g0`
|
||||
- treesitter symbole `<esc>gT`
|
||||
- peek definition `<esc>gp`
|
||||
- ...
|
@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
func Fib(n int) int {
|
||||
if n < 2 {
|
||||
return n
|
||||
}
|
||||
return Fib(n-1) + Fib(n-2)
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFib(t *testing.T) {
|
||||
require.NoError(t, nil)
|
||||
d := Fib(1)
|
||||
fmt.Println(d)
|
||||
if d != 1 {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// "net/http"
|
||||
"net/http/httptest"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Dog struct {
|
||||
name string
|
||||
age int
|
||||
owner string
|
||||
}
|
||||
|
||||
func NewDog(name string, age int) *Dog {
|
||||
return &Dog{name: name, age: age}
|
||||
}
|
||||
|
||||
// SetOwner
|
||||
func (d *Dog) SetOwner(owner string) {
|
||||
d.owner = owner
|
||||
}
|
||||
|
||||
// SetDogName
|
||||
func (d *Dog) SetDogName(name string) {
|
||||
if d == nil {
|
||||
d = NewDog(name, 0)
|
||||
d.name = name
|
||||
} else {
|
||||
d.name = name
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Dog) SetOwnerUtf8(name []byte) {
|
||||
}
|
||||
|
||||
func fun1() {
|
||||
}
|
||||
|
||||
func fun1_test() {
|
||||
d := NewDog("", 1)
|
||||
NewDog("abc", 12)
|
||||
// fmt.Printf("abc", 1)
|
||||
time.Date(12, 12, 12, 33, 12, 55, 22, nil)
|
||||
|
||||
d.SetOwnerUtf8([]byte{1})
|
||||
w := httptest.NewRecorder()
|
||||
w.Write([]byte{})
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDog(t *testing.T) {
|
||||
require.NoError(t, nil)
|
||||
d := NewDog("Fibi", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCat(t *testing.T) {
|
||||
d := NewDog("Fibi cat", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi cat" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCow(t *testing.T) {
|
||||
require.NoError(t, nil)
|
||||
d := NewDog("Fibi", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHorse(t *testing.T) {
|
||||
d := NewDog("Fibi cat", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi cat" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
//"math"
|
||||
)
|
||||
|
||||
type geometry interface {
|
||||
area() float64
|
||||
perim() float64
|
||||
}
|
||||
|
||||
type rect struct {
|
||||
width float64 `-line:"width"`
|
||||
height float64 `-line:"height"`
|
||||
}
|
||||
|
||||
type rect2 struct {
|
||||
width int `yml:"width"`
|
||||
height int `yml:"height"`
|
||||
}
|
||||
|
||||
func (r rect) area() float64 {
|
||||
return r.width * r.height
|
||||
}
|
||||
|
||||
func (r rect) perim() float64 {
|
||||
return 2*r.width + 2*r.height
|
||||
}
|
||||
|
||||
type circle struct {
|
||||
radius float64
|
||||
}
|
||||
|
||||
func (c circle) area() float64 {
|
||||
return math.Pi * c.radius * c.radius
|
||||
}
|
||||
|
||||
func (c circle) perim() float64 {
|
||||
return 2 * math.Pi * c.radius
|
||||
}
|
||||
|
||||
func measure(g geometry) int {
|
||||
fmt.Println(g)
|
||||
fmt.Println(g.area())
|
||||
fmt.Println(g.perim())
|
||||
return 1
|
||||
}
|
||||
|
||||
func m2() {
|
||||
measure(rect{width: 3})
|
||||
}
|
||||
|
||||
func M2() {
|
||||
measure(rect{width: 3})
|
||||
}
|
||||
|
||||
func interfaceTest() {
|
||||
r := rect{width: 3, height: 4}
|
||||
c := circle{radius: 5}
|
||||
measure(r)
|
||||
measure(c)
|
||||
d := circle{radius: 10}
|
||||
fmt.Println()
|
||||
fun2(d)
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// main
|
||||
// note: this is main func
|
||||
func main() {
|
||||
i := 32
|
||||
i = i + 1
|
||||
fmt.Println("hello, world", i)
|
||||
var uns1 unsafe.Pointer
|
||||
|
||||
var x struct {
|
||||
a int64
|
||||
b bool
|
||||
c string
|
||||
}
|
||||
const M, N = unsafe.Sizeof(x.c), unsafe.Sizeof(x)
|
||||
fmt.Println(M, N, uns1) // 16 32
|
||||
|
||||
var perr *fs.PathError
|
||||
if errors.As(nil, &perr) {
|
||||
fmt.Println(perr.Path)
|
||||
}
|
||||
myfunc3("a", "b")
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// import "fmt"
|
||||
|
||||
type person struct {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
|
||||
type say interface {
|
||||
hello() string
|
||||
}
|
||||
|
||||
type strudent struct {
|
||||
person struct {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
}
|
||||
|
||||
func newPerson(name string) *person {
|
||||
p := person{name: name}
|
||||
fmt.Println("")
|
||||
p.age = 42
|
||||
return &p
|
||||
}
|
||||
|
||||
func newPerson2(name, say string) {
|
||||
fmt.Println(name, say)
|
||||
}
|
||||
|
||||
func b() {
|
||||
newPerson2("a", "say")
|
||||
|
||||
ret := measure(rect{width: 3})
|
||||
fmt.Println(ret)
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package test
|
||||
|
||||
type Dog struct {
|
||||
name string
|
||||
age int
|
||||
owner string
|
||||
}
|
||||
|
||||
func NewDog(name string, age int) *Dog {
|
||||
return &Dog{name: name, age: age}
|
||||
}
|
||||
|
||||
// SetOwner
|
||||
func (d *Dog) SetOwner(owner string) {
|
||||
d.owner = owner
|
||||
}
|
||||
|
||||
// SetName
|
||||
func (d *Dog) SetName(name string) {
|
||||
if d == nil {
|
||||
d = NewDog(name, 0)
|
||||
d.name = name
|
||||
} else {
|
||||
d.name = name
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package tekkkt
|
||||
|
||||
type Dog kkktruct {
|
||||
name kkktring
|
||||
age int
|
||||
owner kkktring
|
||||
}
|
||||
|
||||
func NewDog(name kkktring, age int) *Dog {
|
||||
return &Dog{name: name, age: age}
|
||||
}
|
||||
|
||||
// kkketOwner
|
||||
func (d *Dog) kkketOwner(owner kkktring) {
|
||||
d.owner = owner
|
||||
}
|
||||
|
||||
// kkketName
|
||||
func (d *Dog) kkketName(name kkktring) {
|
||||
if d == nil {
|
||||
d = NewDog(name, 0)
|
||||
d.name = name
|
||||
} elkkke {
|
||||
d.name = name
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDog(t *testing.T) {
|
||||
d := NewDog("Fibi", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCat(t *testing.T) {
|
||||
d := NewDog("Fibi cat", 4)
|
||||
fmt.Println(d.name)
|
||||
if d.name != "Fibi cat" {
|
||||
t.Errorf("NewDog failled %v", d)
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "strings"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// type Name2 struct {
|
||||
// f1 string
|
||||
// f2 int
|
||||
// }
|
||||
//
|
||||
// type name4 struct {
|
||||
// f1 string
|
||||
// f2 int
|
||||
// }
|
||||
//
|
||||
// type name5 struct {
|
||||
// f1 string
|
||||
// f2 int
|
||||
// }
|
||||
//
|
||||
// func test2() {
|
||||
// type some struct {
|
||||
// Success bool `-line:"success"`
|
||||
// Failure bool
|
||||
// }
|
||||
//
|
||||
// // myfunc("aaa", "bbb")
|
||||
// }
|
||||
|
||||
func myfunc3(v, v2 string) error {
|
||||
time.After(time.Hour)
|
||||
fmt.Println(v, v2)
|
||||
// fmt.Println(kk)
|
||||
//
|
||||
|
||||
time.Date(2020, 12, 11, 21, 11, 44, 12, nil)
|
||||
time.Date(2020, 1, 11, 11, 11, 2, 1, nil)
|
||||
time.Date(1111, 22, 11, 1, 1, 1, 1, nil)
|
||||
time.Date(12345, 2333, 444, 555, 66, 1, 22, nil)
|
||||
fmt.Println(`kkkkkk`)
|
||||
log.Info(`abc`)
|
||||
log.Infof(`log %s`, `def`)
|
||||
log.Infof(`log %d`, 33)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// func myfunc4() {
|
||||
// // myfunc("aaa", "bbb") // time.Date(12,11, )
|
||||
// // myfunc("abc", "def")
|
||||
// // myfunc("1", "2")
|
||||
// }
|
||||
//
|
||||
// func mytest2() {
|
||||
// i := 1
|
||||
// log.Infof("%d", i)
|
||||
// myfunc4()
|
||||
// }
|
||||
//
|
||||
// func myfunc5() {
|
||||
// hellostring := "hello"
|
||||
// if strings.Contains(hellostring, "hello") {
|
||||
// fmt.Println("it is there")
|
||||
// }
|
||||
// }
|
@ -0,0 +1,101 @@
|
||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||
vim.cmd([[set packpath=/tmp/nvim/site]])
|
||||
|
||||
local package_root = '/tmp/nvim/site/pack'
|
||||
local install_path = package_root .. '/packer/start/packer.nvim'
|
||||
|
||||
local function load_plugins()
|
||||
require('packer').startup({
|
||||
function(use)
|
||||
use({ 'wbthomason/packer.nvim' })
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = { 'python', 'go', 'javascript' },
|
||||
highlight = { enable = true },
|
||||
})
|
||||
end,
|
||||
run = ':TSUpdate',
|
||||
})
|
||||
use({ 'neovim/nvim-lspconfig' })
|
||||
use({ 'ray-x/lsp_signature.nvim' })
|
||||
use({ 'ray-x/aurora' })
|
||||
use({
|
||||
'ray-x/navigator.lua',
|
||||
requires = { 'ray-x/guihua.lua', run = 'cd lua/fzy && make' },
|
||||
config = function()
|
||||
require('navigator').setup({
|
||||
lsp_signature_help = true,
|
||||
})
|
||||
end,
|
||||
})
|
||||
use({ 'L3MON4D3/LuaSnip' })
|
||||
use({
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
},
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
mapping = {
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ select = true })
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
require('cmp').setup.cmdline(':', {
|
||||
sources = {
|
||||
{ name = 'cmdline' },
|
||||
},
|
||||
})
|
||||
require('cmp').setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
config = {
|
||||
package_root = package_root,
|
||||
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.isdirectory(install_path) == 0 then
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
install_path,
|
||||
})
|
||||
load_plugins()
|
||||
require('packer').sync()
|
||||
else
|
||||
load_plugins()
|
||||
end
|
||||
|
||||
vim.cmd('colorscheme aurora')
|
@ -0,0 +1,7 @@
|
||||
const sayHiToSomeone = (callback) => {
|
||||
return callbcak();
|
||||
};
|
||||
|
||||
sayHiToSomeone(()=> {
|
||||
console.log("aaa")
|
||||
})
|
@ -0,0 +1,12 @@
|
||||
function makeFunc() {
|
||||
var browser = 'Mozilla';
|
||||
function displayName() {
|
||||
alert(browser);
|
||||
var message = 'hello ' + browser;
|
||||
alert(message);
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
|
||||
var myFunc = makeFunc();
|
||||
myFunc();
|
@ -0,0 +1,11 @@
|
||||
function curriedDot(vector1) {
|
||||
return function(vector2) {
|
||||
return vector1.reduce(
|
||||
(sum, element, index) => (sum += element * vector2[index]),
|
||||
0
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const sumElements = curriedDot([1, 1, 1]);
|
||||
console.log()
|
@ -0,0 +1 @@
|
||||
const time = new Date(12, 33, )
|
@ -0,0 +1,3 @@
|
||||
console.log("abc");
|
||||
var kingsglove = "abcdefg";
|
||||
console.log()
|
@ -0,0 +1,79 @@
|
||||
import math
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
class Dog:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.tricks = [] # creates a new empty list for each dog
|
||||
|
||||
def add_trick(self, trick):
|
||||
self.tricks.append(trick)
|
||||
|
||||
|
||||
d = Dog('Fido')
|
||||
d.add_trick('roll over')
|
||||
print(d.tricks)
|
||||
|
||||
def test_func():
|
||||
k = [1, 2, 3]
|
||||
sum = 0
|
||||
for i in range(k, 1, 2):
|
||||
sum += 1
|
||||
print(sum)
|
||||
|
||||
def greet(greeting, name):
|
||||
"""
|
||||
This function greets to
|
||||
the person passed in as
|
||||
a parameter
|
||||
"""
|
||||
print(greeting + name + ". Good morning!")
|
||||
|
||||
|
||||
# def greet(greeting, name, msg1, msg2):
|
||||
# """
|
||||
# This function greets to
|
||||
# the person passed in as
|
||||
# a parameter
|
||||
# """
|
||||
# print(greeting + name + ". Good morning!")
|
||||
|
||||
|
||||
greet("a", "b")
|
||||
|
||||
|
||||
def greet2():
|
||||
print("whatever")
|
||||
|
||||
|
||||
def greet3(name):
|
||||
greet2()
|
||||
greet("hey", "dude", "", "")
|
||||
print("whatever" + name)
|
||||
|
||||
def greet3():
|
||||
pass
|
||||
|
||||
|
||||
greet2()
|
||||
|
||||
greet("name", "name")
|
||||
|
||||
greet3("name")
|
||||
greet3("")
|
||||
|
||||
greet("1", "2")
|
||||
|
||||
|
||||
def greeting(greet: int, *, g):
|
||||
"""
|
||||
This function greets to
|
||||
the person passed in as
|
||||
a parameter
|
||||
"""
|
||||
print(greet + g + ". Good morning!")
|
||||
|
||||
|
||||
np.empty(1, order="F")
|
||||
np.empty(1, order="F")
|
@ -0,0 +1,19 @@
|
||||
import pandas as pd
|
||||
import io
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pow()
|
||||
|
||||
|
||||
arg = 111
|
||||
bufio = io
|
||||
filename = 'my_excel.xls'
|
||||
|
||||
|
||||
|
||||
|
||||
df = pd.read_excel(abc, defgh)
|
Loading…
Reference in New Issue