Commit 42ddd058 authored by Tim van Deurzen's avatar Tim van Deurzen

Latest updates.

parent a920a0b6
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
org-agenda-skip-deadline-if-done t org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t org-agenda-skip-scheduled-if-done t
org-clock-rounding-minutes 5 org-clock-rounding-minutes 15
org-clock-persist t org-clock-persist t
org-clock-in-resume t org-clock-in-resume t
org-clock-persist-query-resume nil org-clock-persist-query-resume nil
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package) ;(package! some-package)
(package! evil-colemak-basics) (package! evil-colemak-basics :recipe (:branch "main"))
(package! org-super-agenda) (package! org-super-agenda)
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
email = tim@kompiler.org email = tim@kompiler.org
name = Tim van Deurzen name = Tim van Deurzen
[includeIf "gitdir:~/src/blockport/"]
path = ~/src/blockport/.gitconfig_bux
[includeIf "gitdir:~/src/bux/"]
path = ~/src/bux/.gitconfig_bux
[alias] [alias]
co = checkout co = checkout
br = branch br = branch
...@@ -15,12 +21,15 @@ ...@@ -15,12 +21,15 @@
[url "ssh://git@gitlab.dopey.blockport.io"] [url "ssh://git@gitlab.dopey.blockport.io"]
insteadOf = https://gitlab.dopey.blockport.io insteadOf = https://gitlab.dopey.blockport.io
[url "ssh://git@github.com-vdeurzen-bux/buxapp"]
insteadOf = https://github.com/buxapp
[core] [core]
editor = nvim editor = nvim
pager = delta pager = delta
[delta] [delta]
features = line-numbers decorations side-by-side features = line-numbers decorations
plus-style = "syntax bold auto" plus-style = "syntax bold auto"
minus-style = "syntax bold italic auto" minus-style = "syntax bold italic auto"
syntax-theme = "gruvbox-light" syntax-theme = "gruvbox-light"
......
local lsp_config = require("lspconfig")
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
lsp_config.gopls.setup({
capabilities = capabilities,
settings = {
gopls = {
experimentalPostfixCompletions = true,
analyses = {
fieldalignment = true,
nilness = true,
unusedwrite = true,
unusedparams = true,
shadow = true,
unreachable = true,
bools = true,
},
staticcheck = true,
usePlaceholders = true,
codelenses = {
gc_details = true,
},
},
},
})
vim.cmd('set noexpandtab')
...@@ -4,3 +4,5 @@ require("keybindings") ...@@ -4,3 +4,5 @@ require("keybindings")
require("plugins") require("plugins")
require("lsp") require("lsp")
require("treesitter") require("treesitter")
require("snippets")
require("automagic")
...@@ -10,6 +10,7 @@ end ...@@ -10,6 +10,7 @@ end
local function basic_configuration() local function basic_configuration()
local options = { local options = {
winbar = "%=%m %f";
hidden = true; hidden = true;
fileformats = "unix,mac,dos"; fileformats = "unix,mac,dos";
modeline = true; modeline = true;
...@@ -31,7 +32,7 @@ local function basic_configuration() ...@@ -31,7 +32,7 @@ local function basic_configuration()
termguicolors = true; termguicolors = true;
background = "dark"; background = "dark";
ttyfast = true; ttyfast = true;
lazyredraw = true; -- lazyredraw = true;
listchars = "tab:»·,nbsp:+,trail:·,extends:→,precedes:←"; listchars = "tab:»·,nbsp:+,trail:·,extends:→,precedes:←";
showcmd = true; showcmd = true;
ruler = true; ruler = true;
...@@ -42,7 +43,7 @@ local function basic_configuration() ...@@ -42,7 +43,7 @@ local function basic_configuration()
wildmenu = true; wildmenu = true;
wildignore = "*.o,*.class,*.hi,*.pdf,*.git,*.blg,*.bbl,*.aux,*.gcno,*.gcda"; wildignore = "*.o,*.class,*.hi,*.pdf,*.git,*.blg,*.bbl,*.aux,*.gcno,*.gcda";
showmode = true; showmode = true;
laststatus = 2; laststatus = 3;
scrolloff = 7; scrolloff = 7;
cmdheight = 2; cmdheight = 2;
tabpagemax = 100; tabpagemax = 100;
......
...@@ -2,50 +2,154 @@ local lspkind = require("lspkind") ...@@ -2,50 +2,154 @@ local lspkind = require("lspkind")
lspkind.init() lspkind.init()
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local luasnip = require("luasnip")
local cmp = require("cmp") local cmp = require("cmp")
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
--require("luasnip").lsp_expand(args.body) luasnip.lsp_expand(args.body)
require("snippy").expand_snippet(args.body) --require("snippy").expand_snippet(args.body)
end, end,
}, },
mapping = { mapping = {
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }), ["<C-f>"] = cmp.mapping.scroll_docs(2),
["<C-e>"] = cmp.mapping({ ['<Down>'] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), { 'i' }),
i = cmp.mapping.abort(), ['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), { 'i' }),
c = cmp.mapping.close(), ['<C-n>'] = cmp.mapping({
}), c = function()
}, if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
sources = cmp.config.sources({ elseif luasnip.expand_or_jumpable() then
{ name = "nvim_lsp" }, luasnip.expand_or_jump()
{ name = "nvim_lua" }, elseif has_words_before() then
{ name = "path" }, cmp.complete()
{ name = "snippy" }, else
{ name = "buffer", keyword_length = 5 }, vim.api.nvim_feedkeys(t('<Down>'), 'n', true)
}), end
end,
formatting = { i = function(fallback)
format = lspkind.cmp_format({ if cmp.visible() then
with_text = true, cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
menu = { elseif luasnip.expand_or_jumpable() then
buffer = "[buf]", luasnip.expand_or_jump()
nvim_lsp = "[LSP]", elseif has_words_before() then
nvim_lua = "[api]", cmp.complete()
path = "[path]", else
luasnip = "[snip]", fallback()
}, end
}), end
}, }),
['<C-p>'] = cmp.mapping({
experimental = { c = function()
native_menu = false, if cmp.visible() then
ghost_text = true, cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
}, elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
vim.api.nvim_feedkeys(t('<Up>'), 'n', true)
end
end,
i = function(fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end
}),
["<C-e>"] = cmp.mapping.close(),
["<c-y>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<c-q>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback()
-- end
-- end, {
-- "i",
-- "s",
-- }),
-- ["<S-Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_prev_item()
-- elseif luasnip.jumpable(-1) then
-- luasnip.jump(-1)
-- else
-- fallback()
-- end
-- end, {
-- "i",
-- "s",
-- }),
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "nvim_lua" },
{ name = "path" },
--{ name = "snippy" },
{ name = "buffer", keyword_length = 5 },
}),
formatting = {
format = lspkind.cmp_format({
with_text = true,
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
},
}),
},
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
experimental = {
native_menu = false,
ghost_text = true,
},
}) })
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
...@@ -31,7 +31,7 @@ local keymap = { ...@@ -31,7 +31,7 @@ local keymap = {
r = { "<Cmd>lua vim.lsp.buf.rename()<CR>", "rename" }, r = { "<Cmd>lua vim.lsp.buf.rename()<CR>", "rename" },
s = { "<Cmd>lua vim.lsp.buf.references()<CR>", "find" }, s = { "<Cmd>lua vim.lsp.buf.references()<CR>", "find" },
p = { "<cmd>lua vim.lsp.buf.hover()<CR>", "preview definition" }, p = { "<cmd>lua vim.lsp.buf.hover()<CR>", "preview definition" },
f = { "<Cmd>lua vim.lsp.buf.formatting()<CR>", "format" }, f = { "<Cmd>lua vim.lsp.buf.format({ async = true })<CR>", "format" },
d = { "<Cmd>lua vim.lsp.buf.definition()<CR>", "go to definition" }, d = { "<Cmd>lua vim.lsp.buf.definition()<CR>", "go to definition" },
i = { "<Cmd>lua vim.lsp.buf.implementation()<CR>", "go to definition" }, i = { "<Cmd>lua vim.lsp.buf.implementation()<CR>", "go to definition" },
t = { "<Cmd>LspTroubleToggle lsp_workspace_diagnostics<CR>", "open LspTrouble" }, t = { "<Cmd>LspTroubleToggle lsp_workspace_diagnostics<CR>", "open LspTrouble" },
......
local lsp_config = require("lspconfig") local lsp_config = require("lspconfig")
-- local ih = require("inlay-hints")
--
-- ih.setup({
-- only_current_line = true,
-- eol = {
-- right_align = true,
-- right_align_padding = 10,
-- }
-- })
-- lsp_lines includes a better solution, disabled to avoid double diags.
vim.diagnostic.config({
virtual_text = false,
})
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
lsp_config.terraformls.setup({})
lsp_config.java_language_server.setup({
cmd = { "/usr/bin/java-language-server" },
})
lsp_config.gopls.setup({ lsp_config.gopls.setup({
capabilities = capabilities, capabilities = capabilities,
settings = { -- on_attach = function(c, b)
gopls = { -- ih.on_attach(c, b)
experimentalPostfixCompletions = true, -- end,
analyses = { settings = {
fieldalignment = true, gopls = {
nilness = true, experimentalPostfixCompletions = true,
unusedwrite = true, analyses = {
unusedparams = true, fieldalignment = true,
shadow = true, nilness = true,
unreachable = true, unusedwrite = true,
bools = true, unusedparams = true,
}, unusedvariable = true,
staticcheck = true, shadow = true,
usePlaceholders = true, unreachable = true,
codelenses = { bools = true,
gc_details = true, useany = true,
}, },
}, staticcheck = true,
}, usePlaceholders = true,
codelenses = {
gc_details = true,
},
semanticTokens = true,
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
},
},
}) })
-- lsp_config.rust_analyzer.setup{ -- lsp_config.rust_analyzer.setup{
...@@ -46,171 +81,179 @@ lsp_config.gopls.setup({ ...@@ -46,171 +81,179 @@ lsp_config.gopls.setup({
-- } -- }
local opts = { local opts = {
tools = { -- rust-tools options tools = { -- rust-tools options
-- Automatically set inlay hints (type hints) -- Automatically set inlay hints (type hints)
autoSetHints = true, autoSetHints = true,
-- Whether to show hover actions inside the hover window -- Whether to show hover actions inside the hover window
-- This overrides the default hover handler -- This overrides the default hover handler
hover_with_actions = true, -- hover_with_actions = true,
runnables = { runnables = {
-- whether to use telescope for selection menu or not -- whether to use telescope for selection menu or not
use_telescope = true, use_telescope = true,
-- rest of the opts are forwarded to telescope -- rest of the opts are forwarded to telescope
}, },
debuggables = { debuggables = {
-- whether to use telescope for selection menu or not -- whether to use telescope for selection menu or not
use_telescope = true, use_telescope = true,
-- rest of the opts are forwarded to telescope -- rest of the opts are forwarded to telescope
}, },
-- These apply to the default RustSetInlayHints command -- These apply to the default RustSetInlayHints command
inlay_hints = { inlay_hints = {
-- Only show inlay hints for the current line -- Only show inlay hints for the current line
only_current_line = false, only_current_line = false,
-- Event which triggers a refersh of the inlay hints. -- Event which triggers a refersh of the inlay hints.
-- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but
-- not that this may cause higher CPU usage. -- not that this may cause higher CPU usage.
-- This option is only respected when only_current_line and -- This option is only respected when only_current_line and
-- autoSetHints both are true. -- autoSetHints both are true.
only_current_line_autocmd = "CursorHold", only_current_line_autocmd = "CursorHold",
-- wheter to show parameter hints with the inlay hints or not -- wheter to show parameter hints with the inlay hints or not
show_parameter_hints = true, show_parameter_hints = true,
-- prefix for parameter hints -- prefix for parameter hints
parameter_hints_prefix = "<- ", parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining) -- prefix for all the other hints (type, chaining)
other_hints_prefix = "=> ", other_hints_prefix = "=> ",
-- whether to align to the length of the longest line in the file -- whether to align to the length of the longest line in the file
max_len_align = false, max_len_align = false,
-- padding from the left if max_len_align is true -- padding from the left if max_len_align is true
max_len_align_padding = 1, max_len_align_padding = 1,
-- whether to align to the extreme right or not -- whether to align to the extreme right or not
right_align = false, right_align = false,
-- padding from the right if right_align is true -- padding from the right if right_align is true
right_align_padding = 7, right_align_padding = 7,
-- The color of the hints -- The color of the hints
highlight = "Comment", highlight = "Comment",
}, },
hover_actions = { hover_actions = {
-- the border that is used for the hover window -- the border that is used for the hover window
-- see vim.api.nvim_open_win() -- see vim.api.nvim_open_win()
border = { border = {
{ "╭", "FloatBorder" }, { "╭", "FloatBorder" },
{ "─", "FloatBorder" }, { "─", "FloatBorder" },
{ "╮", "FloatBorder" }, { "╮", "FloatBorder" },
{ "│", "FloatBorder" }, { "│", "FloatBorder" },
{ "╯", "FloatBorder" }, { "╯", "FloatBorder" },
{ "─", "FloatBorder" }, { "─", "FloatBorder" },
{ "╰", "FloatBorder" }, { "╰", "FloatBorder" },
{ "│", "FloatBorder" }, { "│", "FloatBorder" },
}, },
-- whether the hover action window gets automatically focused -- whether the hover action window gets automatically focused
auto_focus = false, auto_focus = false,
}, },
}, },
-- all the opts to send to nvim-lspconfig -- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim -- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
server = {}, -- rust-analyer options server = {}, -- rust-analyer options
} }
require("rust-tools").setup(opts) require("rust-tools").setup(opts)
lsp_config.angularls.setup({ lsp_config.angularls.setup({
capabilities = capabilities, capabilities = capabilities,
}) })
lsp_config.yamlls.setup({ lsp_config.yamlls.setup({
capabilities = capabilities, capabilities = capabilities,
}) })
lsp_config.metals.setup({ lsp_config.metals.setup({
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
metals = { metals = {
superMethodLensesEnabled = true, superMethodLensesEnabled = true,
showInferredType = true, showInferredType = true,
showImplicitArguments = true, showImplicitArguments = true,
}, },
}, },
}) })
lsp_config.dartls.setup({}) lsp_config.dartls.setup({})
lsp_config.texlab.setup({})
lsp_config.ccls.setup({ lsp_config.ccls.setup({
capabilities = capabilities, capabilities = capabilities,
}) })
lsp_config.sumneko_lua.setup({ lsp_config.sumneko_lua.setup({
cmd = { "/usr/bin/lua-language-server" }, cmd = { "/usr/bin/lua-language-server" },
capabilities = capabilities, -- on_attach = function(c, b)
settings = { -- ih.on_attach(c, b)
Lua = { -- end,
runtime = { capabilities = capabilities,
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) settings = {
version = "LuaJIT", Lua = {
-- Setup your lua path hint = {
path = vim.split(package.path, ";"), enable = true,
}, },
diagnostics = { runtime = {
-- Get the language server to recognize the `vim` global -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
globals = { "vim" }, version = "LuaJIT",
}, -- Setup your lua path
workspace = { path = vim.split(package.path, ";"),
-- Make the server aware of Neovim runtime files },
library = { diagnostics = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true, -- Get the language server to recognize the `vim` global
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, globals = { "vim" },
}, },
}, workspace = {
-- Do not send telemetry data containing a randomized but unique identifier -- Make the server aware of Neovim runtime files
telemetry = { library = {
enable = false, [vim.fn.expand("$VIMRUNTIME/lua")] = true,
}, [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
}, },
}, },
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}) })
local eslint = { local eslint = {
lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}", lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
lintStdin = true, lintStdin = true,
lintFormats = { "%f:%l:%c: %m" }, lintFormats = { "%f:%l:%c: %m" },
lintIgnoreExitCode = true, lintIgnoreExitCode = true,
formatCommand = "eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}", formatCommand = "eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}",
formatStdin = true, formatStdin = true,
} }
lsp_config.efm.setup({ lsp_config.efm.setup({
init_options = { documentFormatting = true }, init_options = { documentFormatting = true },
filetypes = { "javascript", "typescript" }, filetypes = { "javascript", "typescript" },
root_dir = function(fname) root_dir = function(fname)
return lsp_config.util.root_pattern("tsconfig.json")(fname) return lsp_config.util.root_pattern("tsconfig.json")(fname)
or lsp_config.util.root_pattern(".eslintrc.js", ".git")(fname) or lsp_config.util.root_pattern(".eslintrc.js", ".git")(fname)
end, end,
settings = { settings = {
rootMarkers = { ".eslintrc.js", ".git/" }, rootMarkers = { ".eslintrc.js", ".git/" },
languages = { languages = {
javascript = { eslint }, javascript = { eslint },
typescript = { eslint }, typescript = { eslint },
}, },
}, },
}) })
-- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( -- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
...@@ -247,14 +290,15 @@ lsp_config.efm.setup({ ...@@ -247,14 +290,15 @@ lsp_config.efm.setup({
-- }) -- })
if vim.g.snippets ~= "luasnip" then if vim.g.snippets ~= "luasnip" then
return return
end end
local ls = require("luasnip") local ls = require("luasnip")
require("snippets")
ls.config.set_config({ ls.config.set_config({
history = true, history = true,
updateevents = "TextChanged,TextChangedI", updateevents = "TextChanged,TextChangedI",
}) })
-- create snippet -- create snippet
...@@ -277,30 +321,30 @@ local t = ls.t -- text node ...@@ -277,30 +321,30 @@ local t = ls.t -- text node
local d = ls.d -- dynamic node local d = ls.d -- dynamic node
local str = function(text) local str = function(text)
return t({ text }) return t({ text })
end end
local newline = function(text) local newline = function(text)
return t({ "", text }) return t({ "", text })
end end
local str_snip = function(trig, expanded) local str_snip = function(trig, expanded)
return ls.parser.parse_snippet({ trig = trig }, expanded) return ls.parser.parse_snippet({ trig = trig }, expanded)
end end
local tbl_snip = function(t) local tbl_snip = function(t)
return snippet({ trig = t.trig, dscr = t.desc }, { unpack(t) }) return snippet({ trig = t.trig, dscr = t.desc }, { unpack(t) })
end end
local function char_count_same(c1, c2) local function char_count_same(c1, c2)
local line = vim.api.nvim_get_current_line() local line = vim.api.nvim_get_current_line()
local _, ct1 = string.gsub(line, c1, "") local _, ct1 = string.gsub(line, c1, "")
local _, ct2 = string.gsub(line, c2, "") local _, ct2 = string.gsub(line, c2, "")
return ct1 == ct2 return ct1 == ct2
end end
local function neg(fn, ...) local function neg(fn, ...)
return not fn(...) return not fn(...)
end end
-- {{{ Go stuff -- {{{ Go stuff
...@@ -310,9 +354,9 @@ local ts_utils = require("nvim-treesitter.ts_utils") ...@@ -310,9 +354,9 @@ local ts_utils = require("nvim-treesitter.ts_utils")
local get_node_text = vim.treesitter.get_node_text local get_node_text = vim.treesitter.get_node_text
vim.treesitter.set_query( vim.treesitter.set_query(
"go", "go",
"LuaSnip_Result", "LuaSnip_Result",
[[ [[
[ [
(method_declaration result: (*) @id) (method_declaration result: (*) @id)
(function_declaration result: (*) @id) (function_declaration result: (*) @id)
...@@ -322,152 +366,154 @@ vim.treesitter.set_query( ...@@ -322,152 +366,154 @@ vim.treesitter.set_query(
) )
local transform = function(text, info) local transform = function(text, info)
if text == "int" then if text == "int" then
return str("0") return str("0")
elseif text == "error" then elseif text == "error" then
if info then if info then
info.index = info.index + 1 info.index = info.index + 1
return c(info.index, { return c(info.index, {
str(string.format('errors.Wrap(%s, "%s")', info.err_name, info.func_name)), str(string.format('errors.Wrap(%s, "%s")', info.err_name, info.func_name)),
str(info.err_name), str(info.err_name),
}) })
else else
return str("err") return str("err")
end end
elseif text == "bool" then elseif text == "bool" then
return str("false") return str("false")
elseif string.find(text, "*", 1, true) then elseif string.find(text, "*", 1, true) then
return str("nil") return str("nil")
end end
return str(text) return str(text)
end end
local handlers = { local handlers = {
["parameter_list"] = function(node, info) ["parameter_list"] = function(node, info)
local result = {} local result = {}
local count = node:named_child_count() local count = node:named_child_count()
for i = 0, count - 1 do for i = 0, count - 1 do
table.insert(result, transform(get_node_text(node:named_child(i), 0), info)) table.insert(result, transform(get_node_text(node:named_child(i), 0), info))
if i ~= count - 1 then if i ~= count - 1 then
table.insert(result, t({ ", " })) table.insert(result, t({ ", " }))
end end
end end
return result return result
end, end,
["type_identifier"] = function(node, info) ["type_identifier"] = function(node, info)
local text = get_node_text(node, 0) local text = get_node_text(node, 0)
return { transform(text, info) } return { transform(text, info) }
end, end,
} }
local function go_result_type(info) local function go_result_type(info)
local cursor_node = ts_utils.get_node_at_cursor() local cursor_node = ts_utils.get_node_at_cursor()
local scope = ts_locals.get_scope_tree(cursor_node, 0) local scope = ts_locals.get_scope_tree(cursor_node, 0)
local function_node local function_node
for _, v in ipairs(scope) do for _, v in ipairs(scope) do
if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then
function_node = v function_node = v
break break
end end
end end
local query = vim.treesitter.get_query("go", "LuaSnip_Result") local query = vim.treesitter.get_query("go", "LuaSnip_Result")
for id, node in query:iter_captures(function_node, 0) do for id, node in query:iter_captures(function_node, 0) do
if handlers[node:type()] then if handlers[node:type()] then
return handlers[node:type()](node, info) return handlers[node:type()](node, info)
end end
end end
end end
-- }}} -- }}}
local shortcut = function(val) local shortcut = function(val)
if type(val) == "string" then if type(val) == "string" then
return { t({ val }), i(0) } return { t({ val }), i(0) }
end end
if type(val) == "table" then if type(val) == "table" then
for k, v in ipairs(val) do for k, v in ipairs(val) do
if type(v) == "string" then if type(v) == "string" then
val[k] = t({ v }) val[k] = t({ v })
end end
end end
end end
return val return val
end end
local make = function(tbl) local make = function(tbl)
local result = {} local result = {}
for k, v in pairs(tbl) do for k, v in pairs(tbl) do
table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v)))) table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v))))
end end
return result return result
end end
local same = function(index) local same = function(index)
return f(function(args) return f(function(args)
return args[1] return args[1]
end, { index }) end, { index })
end end
local snippets = {} local snippets = {}
local go_ret_vals = function(args, old_state) local go_ret_vals = function(args, old_state)
local info = { index = 0, err_name = args[1][1], func_name = args[2][1] } local info = { index = 0, err_name = args[1][1], func_name = args[2][1] }
return snippet_from_nodes(nil, go_result_type(info)) return snippet_from_nodes(nil, go_result_type(info))
end end
--stylua: ignore --stylua: ignore
snippets.go = make { snippets.go = make {
main = { main = {
t { "func main() {", "\t" }, t { "func main() {", "\t" },
i(0), i(0),
t { "", "}" }, t { "", "}" },
}, },
ef = { ef = {
i(1, { "val" }), i(1, { "val" }),
str ", err := ", str ", err := ",
i(2, { "f" }), i(2, { "f" }),
str "(", str "(",
i(3), i(3),
str ")", str ")",
i(0), i(0),
}, },
efi = { efi = {
i(1, { "val" }), i(1, { "val" }),
", ", ", ",
i(2, { "err" }), i(2, { "err" }),
" := ", " := ",
i(3, { "f" }), i(3, { "f" }),
"(", "(",
i(4), i(4),
")", ")",
t { "", "if " }, t { "", "if " },
same(2), same(2),
t { " != nil {", "\treturn " }, t { " != nil {", "\treturn " },
d(5, go_ret_vals, { 2, 3 }), d(5, go_ret_vals, { 2, 3 }),
t { "", "}" }, t { "", "}" },
i(0), i(0),
}, },
-- TODO: Fix this up so that it actually uses the tree sitter thing -- TODO: Fix this up so that it actually uses the tree sitter thing
ie = { "if err != nil {", "\treturn err", i(0), "}" }, ie = { "if err != nil {", "\treturn err", i(0), "}" },
} }
vim.cmd([[augroup lsp]])
vim.cmd [[augroup lsp]] vim.cmd([[au!]])
vim.cmd [[au!]] vim.cmd([[au FileType scala,sbt lua require("metals").initialize_or_attach({})]])
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach({})]] vim.cmd([[augroup end]])
vim.cmd [[augroup end]]
local metals_config = require("metals").bare_config() local metals_config = require("metals").bare_config()
metals_config.settings = { metals_config.settings = {
showImplicitArguments = true, showImplicitArguments = true,
} }
require('dap-go').setup()
return require("packer").startup(function(use) return require("packer").startup(function(use)
use("wbthomason/packer.nvim") use("wbthomason/packer.nvim")
-- Color schemes -- Color schemes
use("morhetz/gruvbox") use("morhetz/gruvbox")
use("icymind/NeoSolarized") use("icymind/NeoSolarized")
use("romgrk/doom-one.vim") use("romgrk/doom-one.vim")
use({ use({
"tjdevries/gruvbuddy.nvim", "tjdevries/gruvbuddy.nvim",
requires = { "tjdevries/colorbuddy.vim" }, requires = { "tjdevries/colorbuddy.vim" },
config = function() config = function()
--require('colorbuddy').colorscheme('gruvbox') --require('colorbuddy').colorscheme('gruvbox')
vim.cmd([[colo doom-one]]) vim.cmd([[colo doom-one]])
end, end,
}) })
-- UI -- UI
use("ntpeters/vim-better-whitespace") use("ntpeters/vim-better-whitespace")
use("Yggdroot/indentLine") use("Yggdroot/indentLine")
use("haya14busa/incsearch.vim") use("haya14busa/incsearch.vim")
use({ use({
"junegunn/fzf.vim", "junegunn/fzf.vim",
requires = { "junegunn/fzf" }, requires = { "junegunn/fzf" },
}) })
-- Look at feline for a leaner better maintained alternative. -- Look at feline for a leaner better maintained alternative.
use({ use({
"glepnir/galaxyline.nvim", "glepnir/galaxyline.nvim",
branch = "main", branch = "main",
config = function() config = function()
require("statusline") require("statusline")
end, end,
requires = { "kyazdani42/nvim-web-devicons" }, requires = { "kyazdani42/nvim-web-devicons" },
}) })
use("liuchengxu/vista.vim") use("liuchengxu/vista.vim")
use({ use({
"kyazdani42/nvim-tree.lua", "kyazdani42/nvim-tree.lua",
requires = "kyazdani42/nvim-web-devicons", requires = "kyazdani42/nvim-web-devicons",
config = function() config = function()
require("nvim-tree").setup({}) require("nvim-tree").setup({})
end, end,
}) })
use({ use({
"AckslD/nvim-whichkey-setup.lua", "AckslD/nvim-whichkey-setup.lua",
requires = { "liuchengxu/vim-which-key" }, requires = { "liuchengxu/vim-which-key" },
}) })
use({ use({
"akinsho/nvim-bufferline.lua", "akinsho/nvim-bufferline.lua",
requires = "kyazdani42/nvim-web-devicons", requires = "kyazdani42/nvim-web-devicons",
config = function() config = function()
require("bufferline").setup({}) require("bufferline").setup({})
end, end,
}) })
use({
-- Utilities "dnlhc/glance.nvim",
use("editorconfig/editorconfig-vim") config = function()
use({ require('glance').setup({
"nvim-treesitter/nvim-treesitter", height = 18, -- Height of the window
zindex = 45,
run = ":TSUpdate", border = {
enable = false, -- Show window borders. Only horizontal borders allowed
requires = { top_char = '―',
"nvim-treesitter/nvim-treesitter-refactor", bottom_char = '―',
"nvim-treesitter/nvim-treesitter-textobjects", },
}, list = {
}) position = 'right', -- Position of the list window 'left'|'right'
use({ width = 0.33, -- 33% width relative to the active window, min 0.1, max 0.5
"nvim-telescope/telescope.nvim", },
theme = { -- This feature might not work properly in nvim-0.7.2
requires = { enable = true, -- Will generate colors for the plugin based on your current colorscheme
{ "nvim-lua/popup.nvim" }, mode = 'auto', -- 'brighten'|'darken'|'auto', 'auto' will set mode based on the brightness of your colorscheme
{ "nvim-lua/plenary.nvim" }, },
{ "nvim-telescope/telescope-project.nvim" }, hooks = {},
}, folds = {
fold_closed = '',
config = function() fold_open = '',
require("telescope").load_extension("project") folded = true, -- Automatically fold list on startup
end, },
}) indent_lines = {
use("Chiel92/vim-autoformat") enable = true,
use("Raimondi/delimitMate") icon = '│',
use({ },
"Shougo/echodoc.vim", winbar = {
enable = true, -- Available strating from nvim-0.8+
config = function() },
vim.cmd([[let g:echodoc#enable_at_start=1]]) })
end, end,
}) })
-- use({
-- LSP -- "folke/noice.nvim",
use("neovim/nvim-lspconfig") -- config = function()
use({ -- require("noice").setup()
"RishabhRD/nvim-lsputils", -- end,
-- requires = {
requires = { "RishabhRD/popfix" }, -- -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
disable = true, -- "MunifTanjim/nui.nvim",
}) -- -- OPTIONAL:
-- -- `nvim-notify` is only needed, if you want to use the notification view.
use({ -- -- If not available, we use `mini` as the fallback
"nvim-lua/lsp_extensions.nvim", -- "rcarriga/nvim-notify",
-- }
requires = { "neovim/nvim-lspconfig" }, -- })
disable = true, -- use({
-- "b0o/incline.nvim",
config = function() -- config = function()
require("lsp_extensions").inlay_hints({ -- require("incline").setup({
highlight = "Comment", -- debounce_threshold = { falling = 500, rising = 250 },
prefix = " » ", -- render = function(props)
aligned = true, -- local bufname = vim.api.nvim_buf_get_name(props.buf)
only_current_line = false, -- local filename = vim.fn.fnamemodify(bufname, ":t")
enabled = { "ChainingHint" }, -- local diagnostics = get_diagnostic_label(props)
}) -- local modified = vim.api.nvim_buf_get_option(props.buf, "modified") and "bold,italic" or "None"
end, -- local filetype_icon, color = require("nvim-web-devicons").get_icon_color(filename)
})
-- local buffer = {
use({ -- { filetype_icon, guifg = color },
"folke/lsp-trouble.nvim", -- { " " },
disable = true, -- { filename, gui = modified },
requires = "kyazdani42/nvim-web-devicons", -- }
config = function()
require("trouble").setup({ -- if #diagnostics > 0 then
-- your configuration comes here -- table.insert(diagnostics, { "| ", guifg = "grey" })
-- or leave it empty to use the default settings -- end
-- refer to the configuration section below -- for _, buffer_ in ipairs(buffer) do
}) -- table.insert(diagnostics, buffer_)
end, -- end
}) -- return diagnostics
-- end,
-- Completion -- })
use("onsails/lspkind-nvim") -- end
use("hrsh7th/cmp-buffer") -- })
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-nvim-lua") -- Utilities
use("hrsh7th/cmp-nvim-lsp") use("editorconfig/editorconfig-vim")
use("hrsh7th/nvim-cmp") use({
use({ "nvim-treesitter/nvim-treesitter",
"dcampos/cmp-snippy",
requires = { run = ":TSUpdate",
"dcampos/nvim-snippy",
"honza/vim-snippets", requires = {
}, "nvim-treesitter/nvim-treesitter-refactor",
}) "nvim-treesitter/nvim-treesitter-textobjects",
-- use({ },
-- "saadparwaiz1/cmp_luasnip", })
-- disable = true, use({
-- requires = { "nvim-treesitter/playground",
-- "L3MON4D3/LuaSnip",
-- }, requires = {
-- }) "nvim-treesitter/nvim-treesitter"
}
use("windwp/nvim-autopairs") })
use({
use({ "nvim-telescope/telescope.nvim",
"simrat39/rust-tools.nvim",
requires = {
requires = { { "nvim-lua/popup.nvim" },
"nvim-lua/popup.nvim", { "nvim-lua/plenary.nvim" },
}, { "nvim-telescope/telescope-project.nvim" },
}) },
use({ config = function()
"scalameta/nvim-metals", require("telescope").load_extension("project")
requires = { end,
"nvim-lua/plenary.nvim", })
}, use("Chiel92/vim-autoformat")
}) use("Raimondi/delimitMate")
use({
use({ "Shougo/echodoc.vim",
"lewis6991/gitsigns.nvim",
requires = { config = function()
"nvim-lua/plenary.nvim", vim.cmd([[let g:echodoc#enable_at_start=1]])
}, end,
config = function() })
require("gitsigns").setup()
end, -- LSP
}) use("neovim/nvim-lspconfig")
use({
use("tomlion/vim-solidity") "RishabhRD/nvim-lsputils",
requires = { "RishabhRD/popfix" },
disable = true,
})
use({
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
config = function()
require("lsp_lines").setup()
end,
})
use({
"nvim-lua/lsp_extensions.nvim",
requires = { "neovim/nvim-lspconfig" },
disable = true,
config = function()
require("lsp_extensions").inlay_hints({
highlight = "Comment",
prefix = " » ",
aligned = true,
only_current_line = false,
enabled = { "ChainingHint" },
})
end,
})
use('simrat39/inlay-hints.nvim')
use('hashivim/vim-terraform')
use({
'simrat39/symbols-outline.nvim',
config = require("symbols-outline").setup()
})
use({
"rcarriga/nvim-dap-ui",
requires = { "mfussenegger/nvim-dap" }
})
use({
'yriveiro/dap-go.nvim',
requires = { 'nvim-lua/plenary.nvim' }
})
use({
"folke/lsp-trouble.nvim",
disable = true,
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup({
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
})
end,
})
-- Completion
use("onsails/lspkind-nvim")
use("hrsh7th/cmp-buffer")
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-nvim-lua")
use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/nvim-cmp")
-- use({
-- "dcampos/cmp-snippy",
-- requires = {
-- "dcampos/nvim-snippy",
-- "honza/vim-snippets",
-- },
-- })
use({
"saadparwaiz1/cmp_luasnip",
requires = {
"L3MON4D3/LuaSnip",
},
})
-- use({
-- "rafamadriz/friendly-snippets",
-- disable = true,
-- requires = {
-- "L3MON4D3/LuaSnip",
-- },
-- -- config = function()
-- -- require("config.snip").setup()
-- -- require("luasnip/loaders/from_vscode").load({
-- -- paths = { "~/.local/share/nvim/site/pack/packer/start/friendly-snippets" },
-- -- })
-- -- end,
-- })
use("windwp/nvim-autopairs")
use({
"simrat39/rust-tools.nvim",
requires = {
"nvim-lua/popup.nvim",
},
})
use({
"scalameta/nvim-metals",
requires = {
"nvim-lua/plenary.nvim",
},
})
use({
"lewis6991/gitsigns.nvim",
requires = {
"nvim-lua/plenary.nvim",
},
config = function()
require("gitsigns").setup()
end,
})
use("tomlion/vim-solidity")
end) end)
require("luasnip.loaders.from_vscode").load({paths= {"~/.local/share/nvim/site/pack/packer/start/friendly-snippets/"}})
local ls = require("luasnip")
ls.filetype_extend("all", { "_" })
...@@ -3,10 +3,11 @@ ts_configs.setup { ...@@ -3,10 +3,11 @@ ts_configs.setup {
ensure_installed = { ensure_installed = {
'bash', 'bibtex', 'c', 'comment', 'cpp', 'css', 'go', 'haskell', 'bash', 'bibtex', 'c', 'comment', 'cpp', 'css', 'go', 'haskell',
'html', 'javascript', 'json', 'jsonc', 'julia', 'kotlin', 'latex', 'lua', 'ocaml', 'html', 'javascript', 'json', 'jsonc', 'julia', 'kotlin', 'latex', 'lua', 'ocaml',
'ocaml_interface', 'python', 'regex', 'rust', 'teal', 'toml', 'typescript', 'yaml', 'zig' 'ocaml_interface', 'python', 'regex', 'rust', 'teal', 'toml', 'typescript', 'yaml',
'zig', 'query',
}, },
highlight = {enable = true, use_languagetree = true}, highlight = { enable = true, use_languagetree = true },
indent = {enable = false}, indent = { enable = false },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
keymaps = { keymaps = {
...@@ -17,10 +18,30 @@ ts_configs.setup { ...@@ -17,10 +18,30 @@ ts_configs.setup {
} }
}, },
refactor = { refactor = {
smart_rename = {enable = true, keymaps = {smart_rename = "grr"}}, smart_rename = { enable = true, keymaps = { smart_rename = "grr" } },
highlight_definitions = {enable = true}, highlight_definitions = { enable = true },
highlight_current_scope = { enable = false } highlight_current_scope = { enable = false }
}--, },
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = 'o',
toggle_hl_groups = 'i',
toggle_injected_languages = 't',
toggle_anonymous_nodes = 'a',
toggle_language_display = 'I',
focus_language = 'f',
unfocus_language = 'F',
update = 'R',
goto_node = '<cr>',
show_help = '?',
},
}
--,
--textobjects = { --textobjects = {
-- select = { -- select = {
-- enable = true, -- enable = true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment