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