Compare commits
2 Commits
b9ed19c289
...
06f23dd1a6
Author | SHA1 | Date | |
---|---|---|---|
06f23dd1a6 | |||
5d6834275b |
@ -1,33 +1,33 @@
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
print("expand function")
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
print("expand function")
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set up lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
require('lspconfig')['gopls'].setup {
|
||||
capabilities = capabilities
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
local dap = require("dap")
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "/home/m/dev/sw/binutils-gdb/gdb/gdb",
|
||||
args = { "-i", "dap", "--data-directory=/home/m/dev/sw/binutils-gdb/gdb/data-directory" }
|
||||
type = "executable",
|
||||
command = "/home/m/dev/sw/binutils-gdb/gdb/gdb",
|
||||
args = { "-i", "dap", "--data-directory=/home/m/dev/sw/binutils-gdb/gdb/data-directory" }
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
local str = vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
return str
|
||||
end,
|
||||
args = {},
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
local str = vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
return str
|
||||
end,
|
||||
args = {},
|
||||
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
local dap = require('dap')
|
||||
|
||||
dap.adapters.dart = {
|
||||
type = "executable",
|
||||
-- As of this writing, this functionality is open for review in https://github.com/flutter/flutter/pull/91802
|
||||
command = "flutter",
|
||||
args = {"debug_adapter"}
|
||||
type = "executable",
|
||||
-- As of this writing, this functionality is open for review in https://github.com/flutter/flutter/pull/91802
|
||||
command = "flutter",
|
||||
args = { "debug_adapter" }
|
||||
}
|
||||
dap.configurations.dart = {
|
||||
{
|
||||
type = "dart",
|
||||
request = "launch",
|
||||
name = "Launch Flutter Program",
|
||||
-- The nvim-dap plugin populates this variable with the filename of the current buffer
|
||||
program = "./lib/main.dart",
|
||||
-- The nvim-dap plugin populates this variable with the editor's current working directory
|
||||
cwd = "${workspaceFolder}",
|
||||
-- This gets forwarded to the Flutter CLI tool, substitute `linux` for whatever device you wish to launch
|
||||
toolArgs = {"-d", "linux"}
|
||||
}
|
||||
{
|
||||
type = "dart",
|
||||
request = "launch",
|
||||
name = "Launch Flutter Program",
|
||||
-- The nvim-dap plugin populates this variable with the filename of the current buffer
|
||||
program = "./lib/main.dart",
|
||||
-- The nvim-dap plugin populates this variable with the editor's current working directory
|
||||
cwd = "${workspaceFolder}",
|
||||
-- This gets forwarded to the Flutter CLI tool, substitute `linux` for whatever device you wish to launch
|
||||
toolArgs = { "-d", "linux" }
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
local dap = require("dap")
|
||||
|
||||
dap.adapters.godot = {
|
||||
type = "server",
|
||||
host = '127.0.0.1',
|
||||
port = 6006,
|
||||
type = "server",
|
||||
host = '127.0.0.1',
|
||||
port = 6006,
|
||||
}
|
||||
|
||||
dap.configurations.gdscript = {
|
||||
{
|
||||
type = "godot",
|
||||
request = "launch",
|
||||
name = "Launch scene",
|
||||
project = "${workspaceFolder}",
|
||||
launch_scene = true,
|
||||
}
|
||||
{
|
||||
type = "godot",
|
||||
request = "launch",
|
||||
name = "Launch scene",
|
||||
project = "${workspaceFolder}",
|
||||
launch_scene = true,
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
local dap = require "dap"
|
||||
dap.configurations.lua = {
|
||||
{
|
||||
type = 'nlua',
|
||||
request = 'attach',
|
||||
name = "Attach to running Neovim instance",
|
||||
}
|
||||
{
|
||||
type = 'nlua',
|
||||
request = 'attach',
|
||||
name = "Attach to running Neovim instance",
|
||||
}
|
||||
}
|
||||
|
||||
dap.adapters.nlua = function(callback, config)
|
||||
callback({ type = 'server', host = config.host or "127.0.0.1", port = config.port or 8086 })
|
||||
callback({ type = 'server', host = config.host or "127.0.0.1", port = config.port or 8086 })
|
||||
end
|
||||
|
@ -5,20 +5,20 @@ vim.keymap.set('n', '<F12>', function() require('dap').step_out() end)
|
||||
vim.keymap.set('n', '<Leader>b', function() require('dap').toggle_breakpoint() end)
|
||||
vim.keymap.set('n', '<Leader>B', function() require('dap').set_breakpoint() end)
|
||||
vim.keymap.set('n', '<Leader>lp',
|
||||
function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end)
|
||||
function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end)
|
||||
vim.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end)
|
||||
vim.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end)
|
||||
vim.keymap.set({ 'n', 'v' }, '<Leader>dh', function()
|
||||
require('dap.ui.widgets').hover()
|
||||
require('dap.ui.widgets').hover()
|
||||
end)
|
||||
vim.keymap.set({ 'n', 'v' }, '<Leader>dp', function()
|
||||
require('dap.ui.widgets').preview()
|
||||
require('dap.ui.widgets').preview()
|
||||
end)
|
||||
vim.keymap.set('n', '<Leader>df', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.frames)
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.frames)
|
||||
end)
|
||||
vim.keymap.set('n', '<Leader>ds', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.scopes)
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.scopes)
|
||||
end)
|
||||
|
@ -2,4 +2,3 @@ vim.api.nvim_set_keymap('n', '<leader>do', '<cmd>lua vim.diagnostic.open_float()
|
||||
vim.api.nvim_set_keymap('n', '<leader>d[', '<cmd>lua vim.diagnostic.goto_prev()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>d]', '<cmd>lua vim.diagnostic.goto_next()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>dd', '<cmd>Telescope diagnostics<CR>', { noremap = true, silent = true })
|
||||
|
||||
|
@ -4,11 +4,11 @@ require('litee.lib').setup({})
|
||||
require('litee.calltree').setup({})
|
||||
|
||||
require('litee.lib').setup({
|
||||
tree = {
|
||||
icon_set = "codicons"
|
||||
},
|
||||
panel = {
|
||||
orientation = "right",
|
||||
panel_size = 30
|
||||
}
|
||||
tree = {
|
||||
icon_set = "codicons"
|
||||
},
|
||||
panel = {
|
||||
orientation = "right",
|
||||
panel_size = 30
|
||||
}
|
||||
})
|
||||
|
@ -1,10 +1,10 @@
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'sh',
|
||||
callback = function()
|
||||
vim.lsp.start({
|
||||
print("Bash lsp started");
|
||||
name = 'bash-language-server',
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
})
|
||||
end,
|
||||
pattern = 'sh',
|
||||
callback = function()
|
||||
vim.lsp.start({
|
||||
print("Bash lsp started"),
|
||||
name = 'bash-language-server',
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
@ -1,3 +1,3 @@
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.clangd.setup{}
|
||||
lspconfig.clangd.setup {}
|
||||
|
@ -1,25 +1,25 @@
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(ev)
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>gr', builtin.lsp_references);
|
||||
callback = function(ev)
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>gr', builtin.lsp_references);
|
||||
|
||||
local opts = { noremap = true, silent = false, buffer = ev.buf }
|
||||
local opts = { noremap = true, silent = false, buffer = ev.buf }
|
||||
|
||||
vim.keymap.set('n', '<leader>ci', vim.lsp.buf.incoming_calls, opts);
|
||||
vim.keymap.set('n', '<leader>gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>ga', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
vim.keymap.set('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.keymap.set('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float({scope="buffer"})<CR>', opts)
|
||||
vim.keymap.set('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.keymap.set('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', '<leader>fo', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
end,
|
||||
vim.keymap.set('n', '<leader>ci', vim.lsp.buf.incoming_calls, opts);
|
||||
vim.keymap.set('n', '<leader>gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>ga', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
vim.keymap.set('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.keymap.set('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float({scope="buffer"})<CR>', opts)
|
||||
vim.keymap.set('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.keymap.set('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', '<leader>fo', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
@ -2,6 +2,6 @@
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require'lspconfig'.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
require 'lspconfig'.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
require("lspconfig").gdscript.setup{}
|
||||
require("lspconfig").gdscript.setup {}
|
||||
|
@ -1,14 +1,14 @@
|
||||
local nvim_lsp = require ('lspconfig')
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
nvim_lsp.gopls.setup{
|
||||
cmd = {'gopls'},
|
||||
filetypes = {"go", "gomod"},
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
nvim_lsp.gopls.setup {
|
||||
cmd = { 'gopls' },
|
||||
filetypes = { "go", "gomod" },
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require'lspconfig'.html.setup {
|
||||
capabilities = capabilities,
|
||||
require 'lspconfig'.html.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
-- lua lsp is not installed by packer but is actually a package installed with pacman
|
||||
require 'lspconfig'.lua_ls.setup {
|
||||
on_init = function(client)
|
||||
local path = client.workspace_folders[1].name
|
||||
if not vim.loop.fs_stat(path .. '/.luarc.json') and not vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
||||
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
on_init = function(client)
|
||||
local path = client.workspace_folders[1].name
|
||||
if not vim.loop.fs_stat(path .. '/.luarc.json') and not vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
||||
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
|
||||
end
|
||||
return true
|
||||
end
|
||||
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
|
||||
end
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
require'lspconfig'.phpactor.setup{}
|
||||
require 'lspconfig'.phpactor.setup {}
|
||||
|
@ -1,12 +1,12 @@
|
||||
local rt = require("rust-tools")
|
||||
|
||||
rt.setup({
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>ga", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>ga", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
17
after/plugin/tests/neotest.lua
Normal file
17
after/plugin/tests/neotest.lua
Normal file
@ -0,0 +1,17 @@
|
||||
local neotest_ns = vim.api.nvim_create_namespace("neotest")
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
format = function(diagnostic)
|
||||
local message =
|
||||
diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
|
||||
return message
|
||||
end,
|
||||
},
|
||||
}, neotest_ns)
|
||||
|
||||
require("neotest").setup({
|
||||
-- your neotest config here
|
||||
adapters = {
|
||||
require("neotest-go"),
|
||||
},
|
||||
})
|
@ -1,27 +1,27 @@
|
||||
require 'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "go", "rust", "toml", "c", "lua", "vim", "vimdoc", "query" },
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "go", "rust", "toml", "c", "lua", "vim", "vimdoc", "query" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
ident = { enable = true },
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = nil,
|
||||
}
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
ident = { enable = true },
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = nil,
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,36 @@
|
||||
local group = vim.api.nvim_create_augroup("autoformat", {})
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.lsp.buf.format { async = false }
|
||||
end
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.lsp.buf.format { async = false }
|
||||
end
|
||||
})
|
||||
|
||||
local gotests = require("myworkflow.go-tests")
|
||||
local atgroup = vim.api.nvim_create_augroup("autotest", {})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePost',
|
||||
{
|
||||
group = atgroup,
|
||||
pattern = { "*.go" },
|
||||
callback = function()
|
||||
gotests.goRunTests()
|
||||
end
|
||||
}
|
||||
{
|
||||
group = atgroup,
|
||||
pattern = { "*.go" },
|
||||
callback = function()
|
||||
gotests.goRunTests()
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
pattern = { "*" },
|
||||
group = atgroup,
|
||||
nested = true,
|
||||
callback = function()
|
||||
-- we have to defer the autocommand, because otherwise treesitter
|
||||
-- will not highlight syntax (all code is plain white)
|
||||
vim.defer_fn(function()
|
||||
local gomod_exists = vim.fn.filereadable("go.mod")
|
||||
if gomod_exists ~= 0 then
|
||||
gotests.goRunTests()
|
||||
end
|
||||
end, 500)
|
||||
end
|
||||
pattern = { "*" },
|
||||
group = atgroup,
|
||||
nested = true,
|
||||
callback = function()
|
||||
-- we have to defer the autocommand, because otherwise treesitter
|
||||
-- will not highlight syntax (all code is plain white)
|
||||
vim.defer_fn(function()
|
||||
local gomod_exists = vim.fn.filereadable("go.mod")
|
||||
if gomod_exists ~= 0 then
|
||||
gotests.goRunTests()
|
||||
end
|
||||
end, 500)
|
||||
end
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
local M = {
|
||||
results = {}
|
||||
results = {}
|
||||
}
|
||||
|
||||
local ns = vim.api.nvim_create_namespace("live-tests")
|
||||
@ -24,154 +24,154 @@ local test_function_query_string = [[
|
||||
]]
|
||||
|
||||
local find_test_line = function(go_bufnr, name)
|
||||
local formatted = string.format(test_function_query_string, name)
|
||||
local query = vim.treesitter.query.parse("go", formatted)
|
||||
local parser = vim.treesitter.get_parser(go_bufnr, "go", {})
|
||||
local tree = parser:parse()[1]
|
||||
local root = tree:root()
|
||||
local formatted = string.format(test_function_query_string, name)
|
||||
local query = vim.treesitter.query.parse("go", formatted)
|
||||
local parser = vim.treesitter.get_parser(go_bufnr, "go", {})
|
||||
local tree = parser:parse()[1]
|
||||
local root = tree:root()
|
||||
|
||||
for id, node in query:iter_captures(root, go_bufnr, 0, -1) do
|
||||
if id == 1 then
|
||||
local range = { node:range() }
|
||||
return range[1]
|
||||
end
|
||||
end
|
||||
for id, node in query:iter_captures(root, go_bufnr, 0, -1) do
|
||||
if id == 1 then
|
||||
local range = { node:range() }
|
||||
return range[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function clear(table)
|
||||
for k in pairs(table) do
|
||||
table[k] = nil
|
||||
end
|
||||
for k in pairs(table) do
|
||||
table[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('GoTest', function()
|
||||
M.goRunTests()
|
||||
M.goRunTests()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command('GoPrintResults', function()
|
||||
print(vim.inspect(M.results))
|
||||
print(vim.inspect(M.results))
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command('GoSetTestMarks', function()
|
||||
M.goSetAllMarks()
|
||||
M.goSetAllMarks()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command('GoClearResults', function()
|
||||
clear(M.results)
|
||||
clear(M.results)
|
||||
end, {})
|
||||
|
||||
|
||||
vim.api.nvim_create_user_command('GoClearTestMarks', function()
|
||||
local currbuf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_clear_namespace(currbuf, ns, 0, -1)
|
||||
local currbuf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_clear_namespace(currbuf, ns, 0, -1)
|
||||
end, {})
|
||||
|
||||
local errored = false
|
||||
function M.goRunTests()
|
||||
-- TODO: replace jobstart/jobwait with system()
|
||||
vim.fn.jobstart({ "go", "test", "./...", "-json" }, {
|
||||
stdout_buffered = true,
|
||||
on_stdout = function(_, data)
|
||||
if errored == true then
|
||||
errored = false
|
||||
return
|
||||
end
|
||||
-- TODO: replace jobstart/jobwait with system()
|
||||
vim.fn.jobstart({ "go", "test", "./...", "-json" }, {
|
||||
stdout_buffered = true,
|
||||
on_stdout = function(_, data)
|
||||
if errored == true then
|
||||
errored = false
|
||||
return
|
||||
end
|
||||
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
|
||||
clear(M.results)
|
||||
clear(M.results)
|
||||
|
||||
local collected_messages = {}
|
||||
for _, line in ipairs(data) do
|
||||
if line == "" then goto continue end
|
||||
local decoded = vim.json.decode(line)
|
||||
local collected_messages = {}
|
||||
for _, line in ipairs(data) do
|
||||
if line == "" then goto continue end
|
||||
local decoded = vim.json.decode(line)
|
||||
|
||||
if decoded.Test == nil then
|
||||
goto continue
|
||||
end
|
||||
if decoded.Action == 'pass' or decoded.Action == 'fail' then
|
||||
M.results[decoded.Test] = { Action = decoded.Action }
|
||||
end
|
||||
if decoded.Action == 'output' then
|
||||
local testname = decoded.Test
|
||||
local a = ""
|
||||
if collected_messages[testname] == nil then
|
||||
a = ""
|
||||
else
|
||||
a = collected_messages[testname]
|
||||
end
|
||||
collected_messages[decoded.Test] = a .. decoded.Output
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
-- Merge collected messages into results
|
||||
for test, _ in pairs(M.results) do
|
||||
M.results[test].Message = collected_messages[test]
|
||||
end
|
||||
end,
|
||||
on_stderr = function(_, data)
|
||||
for _, value in pairs(data) do
|
||||
if value and value ~= "" then
|
||||
errored = true
|
||||
print('Error while running tests: ', value)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function()
|
||||
M.goSetAllMarks()
|
||||
end
|
||||
})
|
||||
if decoded.Test == nil then
|
||||
goto continue
|
||||
end
|
||||
if decoded.Action == 'pass' or decoded.Action == 'fail' then
|
||||
M.results[decoded.Test] = { Action = decoded.Action }
|
||||
end
|
||||
if decoded.Action == 'output' then
|
||||
local testname = decoded.Test
|
||||
local a = ""
|
||||
if collected_messages[testname] == nil then
|
||||
a = ""
|
||||
else
|
||||
a = collected_messages[testname]
|
||||
end
|
||||
collected_messages[decoded.Test] = a .. decoded.Output
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
-- Merge collected messages into results
|
||||
for test, _ in pairs(M.results) do
|
||||
M.results[test].Message = collected_messages[test]
|
||||
end
|
||||
end,
|
||||
on_stderr = function(_, data)
|
||||
for _, value in pairs(data) do
|
||||
if value and value ~= "" then
|
||||
errored = true
|
||||
print('Error while running tests: ', value)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function()
|
||||
M.goSetAllMarks()
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
function M.goSetAllMarks()
|
||||
local files = vim.fn.system({ "find", "-type", "f", "-name", "*.go" })
|
||||
local files = vim.fn.system({ "find", "-type", "f", "-name", "*_test.go" })
|
||||
|
||||
local sep = "\n"
|
||||
local filetable = {}
|
||||
for str in string.gmatch(files, "([^" .. sep .. "]+)") do
|
||||
table.insert(filetable, str)
|
||||
end
|
||||
local sep = "\n"
|
||||
local filetable = {}
|
||||
for str in string.gmatch(files, "([^" .. sep .. "]+)") do
|
||||
table.insert(filetable, str)
|
||||
end
|
||||
|
||||
for _, file in ipairs(filetable) do
|
||||
vim.fn.bufadd(file)
|
||||
vim.fn.bufload(file)
|
||||
local bufno = vim.fn.bufnr(file)
|
||||
M.goSetMarks(bufno)
|
||||
end
|
||||
for _, file in ipairs(filetable) do
|
||||
vim.fn.bufadd(file)
|
||||
vim.fn.bufload(file)
|
||||
local bufno = vim.fn.bufnr(file)
|
||||
M.goSetMarks(bufno)
|
||||
end
|
||||
end
|
||||
|
||||
function M.goSetMarks(currbuf)
|
||||
vim.api.nvim_buf_clear_namespace(currbuf, ns, 0, -1)
|
||||
vim.diagnostic.set(ns, currbuf, {}, {})
|
||||
local text = {}
|
||||
local failed = {}
|
||||
vim.api.nvim_buf_clear_namespace(currbuf, ns, 0, -1)
|
||||
vim.diagnostic.set(ns, currbuf, {}, {})
|
||||
local text = {}
|
||||
local failed = {}
|
||||
|
||||
for test, val in pairs(M.results) do
|
||||
local linenum = find_test_line(currbuf, test)
|
||||
if linenum == nil then goto continue end
|
||||
for test, val in pairs(M.results) do
|
||||
local linenum = find_test_line(currbuf, test)
|
||||
if linenum == nil then goto continue end
|
||||
|
||||
if val.Action == 'pass' then
|
||||
text = { "✔" }
|
||||
vim.api.nvim_buf_set_extmark(currbuf, ns, linenum, 0, {
|
||||
virt_text = { text },
|
||||
})
|
||||
elseif val.Action == 'fail' then
|
||||
table.insert(failed, {
|
||||
bufnr = currbuf,
|
||||
lnum = linenum,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = "go-test",
|
||||
message = "Test Failed\n\n" .. val.Message,
|
||||
user_data = {},
|
||||
})
|
||||
end
|
||||
if val.Action == 'pass' then
|
||||
text = { "✔" }
|
||||
vim.api.nvim_buf_set_extmark(currbuf, ns, linenum, 0, {
|
||||
virt_text = { text },
|
||||
})
|
||||
elseif val.Action == 'fail' then
|
||||
table.insert(failed, {
|
||||
bufnr = currbuf,
|
||||
lnum = linenum,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = "go-test",
|
||||
message = "Test Failed\n\n" .. val.Message,
|
||||
user_data = {},
|
||||
})
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
vim.diagnostic.set(ns, currbuf, failed, {})
|
||||
::continue::
|
||||
end
|
||||
vim.diagnostic.set(ns, currbuf, failed, {})
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -2,51 +2,58 @@
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
use { 'nvim-telescope/telescope.nvim',
|
||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
||||
}
|
||||
use { 'nvim-telescope/telescope.nvim',
|
||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
||||
}
|
||||
|
||||
-- fugitive
|
||||
use 'tpope/vim-fugitive'
|
||||
-- fugitive
|
||||
use 'tpope/vim-fugitive'
|
||||
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
-- undotree
|
||||
use 'mbbill/undotree'
|
||||
-- undotree
|
||||
use 'mbbill/undotree'
|
||||
|
||||
-- treesitter
|
||||
use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
|
||||
-- treesitter
|
||||
use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
|
||||
|
||||
-- Colors
|
||||
use 'ellisonleao/gruvbox.nvim'
|
||||
-- Colors
|
||||
use 'ellisonleao/gruvbox.nvim'
|
||||
|
||||
-- LSP
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
use 'akinsho/flutter-tools.nvim'
|
||||
-- LSP
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
use 'akinsho/flutter-tools.nvim'
|
||||
|
||||
-- call tree
|
||||
use 'ldelossa/litee.nvim'
|
||||
use 'ldelossa/litee-calltree.nvim'
|
||||
-- call tree
|
||||
use 'ldelossa/litee.nvim'
|
||||
use 'ldelossa/litee-calltree.nvim'
|
||||
|
||||
-- debugging
|
||||
use 'mfussenegger/nvim-dap'
|
||||
use 'leoluz/nvim-dap-go'
|
||||
use 'rcarriga/nvim-dap-ui'
|
||||
use 'jbyuki/one-small-step-for-vimkind'
|
||||
-- debugging
|
||||
use 'mfussenegger/nvim-dap'
|
||||
use 'leoluz/nvim-dap-go'
|
||||
use 'rcarriga/nvim-dap-ui'
|
||||
use 'jbyuki/one-small-step-for-vimkind'
|
||||
|
||||
-- Autocompletion
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-buffer'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/cmp-cmdline'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
-- Autocompletion
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-buffer'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/cmp-cmdline'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
|
||||
-- Snippets
|
||||
use { "L3MON4D3/LuaSnip" }
|
||||
use { 'saadparwaiz1/cmp_luasnip' }
|
||||
-- Snippets
|
||||
use { "L3MON4D3/LuaSnip" }
|
||||
use { 'saadparwaiz1/cmp_luasnip' }
|
||||
|
||||
-- Project explorer
|
||||
use { 'nvim-tree/nvim-tree.lua', requires = 'nvim-tree/nvim-web-devicons' }
|
||||
-- Tests
|
||||
use 'nvim-neotest/neotest'
|
||||
use 'nvim-neotest/neotest-go'
|
||||
|
||||
-- Neovim development
|
||||
use 'folke/neodev.nvim'
|
||||
|
||||
-- Project explorer
|
||||
use { 'nvim-tree/nvim-tree.lua', requires = 'nvim-tree/nvim-web-devicons' }
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user