mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nvim: stop using nix for nvim
I just wanna work, I don't wanna nix
This commit is contained in:
parent
157b568ab4
commit
3b08674586
30 changed files with 0 additions and 9 deletions
24
.config/nvim/after/plugin/autopairs.lua
Normal file
24
.config/nvim/after/plugin/autopairs.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local Rule = require "nvim-autopairs.rule"
|
||||
local cond = require "nvim-autopairs.conds"
|
||||
local npairs = require "nvim-autopairs"
|
||||
|
||||
npairs.setup()
|
||||
|
||||
-- Intergration with `cmp`
|
||||
local cmp = require "cmp"
|
||||
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
|
||||
-------------------
|
||||
-- Tex and Typst --
|
||||
-------------------
|
||||
npairs.add_rules {
|
||||
Rule("$", "$", { "tex", "typst" })
|
||||
:with_pair(cond.not_before_regex "%a")
|
||||
:with_pair(cond.not_after_regex "%a")
|
||||
:with_move(cond.done),
|
||||
|
||||
Rule("```", "```", "typst")
|
||||
:with_pair(cond.not_before_text "```")
|
||||
:with_cr(cond.done),
|
||||
}
|
||||
229
.config/nvim/after/plugin/cmp.lua
Normal file
229
.config/nvim/after/plugin/cmp.lua
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
local cmp = require "cmp"
|
||||
local ls = require "luasnip"
|
||||
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local cr = function() return t { "", "" } end -- linebreak
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local l = require "luasnip.extras".lambda
|
||||
local rep = require "luasnip.extras".rep
|
||||
local p = require "luasnip.extras".partial
|
||||
local m = require "luasnip.extras".match
|
||||
local n = require "luasnip.extras".nonempty
|
||||
local dl = require "luasnip.extras".dynamic_lambda
|
||||
local fmt = require "luasnip.extras.fmt".fmt
|
||||
local fmta = require "luasnip.extras.fmt".fmta
|
||||
local types = require "luasnip.util.types"
|
||||
local conds = require "luasnip.extras.conditions"
|
||||
local conds_expand = require "luasnip.extras.conditions.expand"
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
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
|
||||
|
||||
-----------------
|
||||
-- Lazy loader --
|
||||
-----------------
|
||||
require "luasnip.loaders.from_vscode".lazy_load { paths = { "./snippets" } }
|
||||
|
||||
----------
|
||||
-- Init --
|
||||
----------
|
||||
ls.setup { update_events = { "TextChanged", "TextChangedI" } }
|
||||
|
||||
-----------
|
||||
-- Typst --
|
||||
-----------
|
||||
local function show_date_typst_entry()
|
||||
return os.date "(year: %Y, month: %m, day: %d, hour: %H, minute: %M, second: %S)"
|
||||
end
|
||||
ls.add_snippets("typst", {
|
||||
s("entry", {
|
||||
t "#entry(",
|
||||
f(show_date_typst_entry),
|
||||
t { ")[", "" },
|
||||
i(0),
|
||||
t { "", "]" },
|
||||
}),
|
||||
})
|
||||
|
||||
local function get_cms()
|
||||
assert(vim.bo.commentstring ~= "", "comment string is not set")
|
||||
local left = vim.bo.commentstring:gsub("%s*%%s.*", "")
|
||||
local right = vim.bo.commentstring:gsub(".*%%s%s*", "")
|
||||
if right == "" then right = left end
|
||||
return { left = left, right = right }
|
||||
end
|
||||
local function horizon(args)
|
||||
local cms = get_cms()
|
||||
local chr = cms.left:sub(-1)
|
||||
local len = vim.fn.strdisplaywidth(args[1][1])
|
||||
|
||||
local acc = cms.left
|
||||
for _ = cms.left:len(), len + cms.right:len() + 1, 1 do
|
||||
acc = acc .. chr
|
||||
end
|
||||
acc = acc .. cms.right
|
||||
|
||||
return acc
|
||||
end
|
||||
local function left()
|
||||
local cms = get_cms()
|
||||
return cms.left .. " "
|
||||
end
|
||||
local function right()
|
||||
local cms = get_cms()
|
||||
return " " .. cms.right
|
||||
end
|
||||
ls.add_snippets("all", {
|
||||
s("banner", {
|
||||
f(horizon, { 1 }),
|
||||
t { "", "" },
|
||||
f(left), i(1), f(right),
|
||||
t { "", "" },
|
||||
f(horizon, { 1 }),
|
||||
}),
|
||||
})
|
||||
|
||||
------------
|
||||
-- Ledger --
|
||||
------------
|
||||
local function show_date_ledger_entry()
|
||||
return os.date "%Y-%m-%d"
|
||||
end
|
||||
-- shortcuts
|
||||
ls.add_snippets("ledger", {
|
||||
s("lessive", {
|
||||
f(show_date_ledger_entry), t " ", t "Lessive (CROUS)", cr(),
|
||||
t "\texpenses 3,00 EUR", cr(),
|
||||
t "\tassets:compte_courant -3,00 EUR", cr(),
|
||||
}),
|
||||
s("sechoir", {
|
||||
f(show_date_ledger_entry), t " ", t "Sechoir (CROUS)", cr(),
|
||||
t "\texpenses 1,50 EUR", cr(),
|
||||
t "\tassets:compte_courant -1,50 EUR", cr(),
|
||||
}),
|
||||
})
|
||||
|
||||
-- generalized entry
|
||||
local id = function(args) return args[1][1] end
|
||||
ls.add_snippets("ledger", {
|
||||
s("entry", {
|
||||
f(show_date_ledger_entry), t " ", i(1), cr(),
|
||||
t "\texpenses:", i(2), t " ", i(3), t " EUR", cr(),
|
||||
t "\tassets:compte_courant -", f(id, { 3 }), t " EUR", cr(),
|
||||
}),
|
||||
s("entry'", {
|
||||
i(1), t " ", i(2), cr(),
|
||||
t "\texpenses:", i(3), t " ", i(4), t " EUR", cr(),
|
||||
t "\tassets:compte_courant -", f(id, { 4 }), t " EUR", cr(),
|
||||
}),
|
||||
})
|
||||
|
||||
-------------
|
||||
-- Haskell --
|
||||
-------------
|
||||
local haskell_snippets = require "haskell-snippets".all
|
||||
ls.add_snippets("haskell", haskell_snippets, { key = "haskell" })
|
||||
|
||||
---------------
|
||||
-- Setup CMP --
|
||||
---------------
|
||||
local Contains = require "utils".Contains
|
||||
local of_filetype = function(fts)
|
||||
local ft = vim.bo.filetype
|
||||
return Contains(fts, ft)
|
||||
end
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = cmp.mapping(function(fallback) -- Next or jump
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif ls.expand_or_locally_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback) -- Previous
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif ls.jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<A-Tab>"] = cmp.mapping(function(fallback) -- Force jump
|
||||
if ls.expand_or_locally_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<CR>"] = cmp.mapping(function(fallback) -- Confirm
|
||||
if cmp.visible() then
|
||||
cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
} ()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-CR>"] = cmp.mapping(function(fallback) -- Confirm and replace
|
||||
if cmp.visible() then
|
||||
cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
} ()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
{ name = "luasnip" },
|
||||
{ name = "nvim_lsp" },
|
||||
{
|
||||
name = "buffer", keyword_length = 10,
|
||||
option = {
|
||||
enable_in_context = function()
|
||||
return of_filetype {
|
||||
"tex",
|
||||
"markdown",
|
||||
"typst",
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "spell", keyword_length = 10,
|
||||
option = {
|
||||
keep_all_entries = true,
|
||||
enable_in_context = function()
|
||||
return of_filetype {
|
||||
"tex",
|
||||
"markdown",
|
||||
"typst",
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
21
.config/nvim/after/plugin/colorizer.lua
Normal file
21
.config/nvim/after/plugin/colorizer.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
local default = {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = false, -- "Name" codes like Blue or blue
|
||||
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
AARRGGBB = false, -- 0xAARRGGBB hex codes
|
||||
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
|
||||
mode = "background",
|
||||
always_update = true,
|
||||
}
|
||||
|
||||
require "colorizer".setup {
|
||||
filetypes = {
|
||||
"*",
|
||||
},
|
||||
user_default_options = default,
|
||||
}
|
||||
38
.config/nvim/after/plugin/gitsigns.lua
Normal file
38
.config/nvim/after/plugin/gitsigns.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
require "gitsigns".setup {
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map("n", "<leader>hj", gs.next_hunk)
|
||||
map("n", "<leader>hk", gs.prev_hunk)
|
||||
|
||||
-- Actions
|
||||
map("n", "<leader>hs", gs.stage_hunk)
|
||||
map("n", "<leader>hu", gs.undo_stage_hunk)
|
||||
map("n", "<leader>hr", gs.reset_hunk)
|
||||
|
||||
map("v", "<leader>hs", function() gs.stage_hunk { vim.fn.line ".", vim.fn.line "v" } end)
|
||||
map("v", "<leader>hr", function() gs.reset_hunk { vim.fn.line ".", vim.fn.line "v" } end)
|
||||
|
||||
map("n", "<leader>hS", gs.stage_buffer)
|
||||
map("n", "<leader>hR", gs.reset_buffer)
|
||||
|
||||
map("n", "<leader>hp", gs.preview_hunk)
|
||||
map("n", "<leader>hb", function() gs.blame_line { full = true } end)
|
||||
map("n", "<leader>tb", gs.toggle_current_line_blame)
|
||||
|
||||
map("n", "<leader>hd", gs.diffthis)
|
||||
map("n", "<leader>hD", function() gs.diffthis "~" end)
|
||||
|
||||
map("n", "<leader>pd", gs.toggle_deleted)
|
||||
|
||||
-- Text object
|
||||
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||
end,
|
||||
}
|
||||
19
.config/nvim/after/plugin/harpoon.lua
Normal file
19
.config/nvim/after/plugin/harpoon.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require "harpoon".setup()
|
||||
|
||||
local ui = require "harpoon.ui"
|
||||
local mark = require "harpoon.mark"
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- add and view
|
||||
map({ "n", "i" }, "<A-c>", function() mark.add_file() end)
|
||||
map({ "n", "i" }, "<A-g>", function() ui.toggle_quick_menu() end)
|
||||
|
||||
-- switch it up!
|
||||
map({ "n", "i" }, "<A-h>", function() ui.nav_file(1) end)
|
||||
map({ "n", "i" }, "<A-t>", function() ui.nav_file(2) end)
|
||||
map({ "n", "i" }, "<A-n>", function() ui.nav_file(3) end)
|
||||
map({ "n", "i" }, "<A-s>", function() ui.nav_file(4) end)
|
||||
map({ "n", "i" }, "<A-m>", function() ui.nav_file(5) end)
|
||||
map({ "n", "i" }, "<A-w>", function() ui.nav_file(6) end)
|
||||
map({ "n", "i" }, "<A-v>", function() ui.nav_file(7) end)
|
||||
map({ "n", "i" }, "<A-z>", function() ui.nav_file(8) end)
|
||||
290
.config/nvim/after/plugin/lsp.lua
Normal file
290
.config/nvim/after/plugin/lsp.lua
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
local map = vim.keymap.set
|
||||
|
||||
local Foreach = require "utils".Foreach
|
||||
|
||||
----------------------
|
||||
-- Language servers --
|
||||
----------------------
|
||||
-- NOTE: put settings into `settings`
|
||||
-- use another `on_attach` field if needed
|
||||
local servers = {
|
||||
bashls = {}, -- Bash
|
||||
clangd = {}, -- C/CPP
|
||||
cssls = {}, -- CSS
|
||||
html = {}, -- HTML
|
||||
jsonls = {}, -- JSON
|
||||
lemminx = {}, -- XML
|
||||
marksman = {}, -- Markdown
|
||||
phpactor = {}, -- PHP
|
||||
pylsp = {}, -- Python
|
||||
pyright = {},
|
||||
taplo = {}, -- TOML
|
||||
texlab = {}, -- texlab
|
||||
tsserver = {}, -- TypeScript
|
||||
vimls = {}, -- Vim Script
|
||||
ocamllsp = {}, -- OCaml
|
||||
|
||||
typst_lsp = { -- Typst
|
||||
settings = {
|
||||
root_dir =
|
||||
vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
|
||||
or vim.loop.cwd(),
|
||||
exportPdf = "never",
|
||||
},
|
||||
},
|
||||
|
||||
lua_ls = { -- Lua
|
||||
settings = {
|
||||
Lua = {
|
||||
format = {
|
||||
defaultConfig = {
|
||||
-- Learn more:
|
||||
-- https://github.com/CppCXY/EmmyLuaCodeStyle/blob/master/docs/format_config.md
|
||||
indent_style = "space",
|
||||
quote_style = "double",
|
||||
call_arg_parentheses = "remove",
|
||||
trailing_table_separator = "smart",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
nil_ls = { -- Nix
|
||||
on_attach = function(_, bufno)
|
||||
vim.api.nvim_buf_set_option(bufno, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
map("n", "<leader>f",
|
||||
function()
|
||||
vim.cmd ":w"
|
||||
vim.cmd [[silent exec "!alejandra %"]]
|
||||
vim.cmd ":e"
|
||||
end,
|
||||
{ buffer = bufno })
|
||||
end,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
-------------
|
||||
-- Helpers --
|
||||
-------------
|
||||
local on_attach = function(client, bufno)
|
||||
vim.api.nvim_buf_set_option(bufno, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
local ts = require "telescope.builtin"
|
||||
local opts = { buffer = bufno }
|
||||
|
||||
map("n", "K", vim.lsp.buf.hover, opts)
|
||||
map("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
map("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
map("n", "gd", vim.lsp.buf.definition, opts)
|
||||
map("n", "gtd", vim.lsp.buf.type_definition, opts)
|
||||
map("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
map("n", "gu", ts.lsp_references, opts)
|
||||
map("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
map("n", "<leader>cl", vim.lsp.codelens.run, opts)
|
||||
map("n", "<leader>r", vim.lsp.buf.rename, opts)
|
||||
map("n", "<leader>f", function() vim.lsp.buf.format { async = true } end, opts)
|
||||
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
require "nvim-navic".attach(client, bufno)
|
||||
end
|
||||
end
|
||||
|
||||
-- Helix style border
|
||||
local border = {
|
||||
{ " ", "FloatBorder" }, { " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" }, { " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" }, { " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" }, { " ", "FloatBorder" },
|
||||
}
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = border
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
end
|
||||
|
||||
-- Type signature
|
||||
require "lsp_signature".setup {
|
||||
doc_lines = 7,
|
||||
bind = true,
|
||||
border = border,
|
||||
hint_enable = false,
|
||||
}
|
||||
|
||||
-- Diagnostic display configuration
|
||||
vim.diagnostic.config { virtual_text = false, severity_sort = true }
|
||||
|
||||
-- Set log level
|
||||
vim.lsp.set_log_level "off"
|
||||
|
||||
-- Gutter symbols setup
|
||||
vim.fn.sign_define("DiagnosticSignError",
|
||||
{ text = "E", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" })
|
||||
vim.fn.sign_define("DiagnosticSignWarn", { text = "W", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })
|
||||
vim.fn.sign_define("DiagnosticSignHint", { text = "H", texthl = "DiagnosticSignHint", numhl = "DiagnosticSignHint" })
|
||||
vim.fn.sign_define("DiagnosticSignInfo", { text = "·", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" })
|
||||
|
||||
-- Capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require "cmp_nvim_lsp".default_capabilities(capabilities)
|
||||
|
||||
----------
|
||||
-- Init --
|
||||
----------
|
||||
require "fidget".setup { text = { spinner = "dots" } }
|
||||
require "neodev".setup()
|
||||
|
||||
-- Folding
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (" %d "):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||
return newVirtText
|
||||
end
|
||||
require "ufo".setup { fold_virt_text_handler = handler }
|
||||
|
||||
Foreach(servers,
|
||||
function(k, v)
|
||||
require "lspconfig"[k].setup {
|
||||
capabilities = capabilities,
|
||||
settings = v.settings,
|
||||
on_attach = function(client, bufno)
|
||||
on_attach(client, bufno)
|
||||
v.on_attach(client, bufno)
|
||||
end,
|
||||
}
|
||||
end)
|
||||
|
||||
------------------------
|
||||
-- Standalone plugins --
|
||||
------------------------
|
||||
-- Java
|
||||
local config = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {
|
||||
-- https://github.com/NixOS/nixpkgs/issues/232822#issuecomment-1564243667
|
||||
-- `-data` argument is necessary
|
||||
"jdt-language-server",
|
||||
"-data", vim.fn.expand "~/.cache/jdtls" .. vim.fn.expand "%:p:h",
|
||||
},
|
||||
root_dir = vim.fs.dirname(vim.fs.find({ "gradlew", ".git", "mvnw" }, { upward = true })[1]),
|
||||
}
|
||||
local jdtls_group = vim.api.nvim_create_augroup("jdtls", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "java" },
|
||||
callback = function()
|
||||
require "jdtls".start_or_attach(config)
|
||||
end,
|
||||
group = jdtls_group,
|
||||
})
|
||||
|
||||
-- Scala
|
||||
local metals = require "metals"
|
||||
local metals_config = metals.bare_config()
|
||||
metals_config.capabilities = capabilities
|
||||
metals_config.settings.useGlobalExecutable = true
|
||||
|
||||
require "dap".configurations.scala = {
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "RunOrTest",
|
||||
metals = { runType = "runOrTestFile" },
|
||||
},
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "Test Target",
|
||||
metals = { runType = "testTarget" },
|
||||
},
|
||||
}
|
||||
|
||||
metals_config.on_attach = function(client, bufnr)
|
||||
metals.setup_dap()
|
||||
|
||||
map("n", "<leader>ws", metals.hover_worksheet)
|
||||
|
||||
map("n", "<leader>dc", require "dap".continue)
|
||||
map("n", "<leader>dr", require "dap".repl.toggle)
|
||||
map("n", "<leader>dK", require "dap.ui.widgets".hover)
|
||||
map("n", "<leader>dt", require "dap".toggle_breakpoint)
|
||||
map("n", "<leader>dso", require "dap".step_over)
|
||||
map("n", "<leader>dsi", require "dap".step_into)
|
||||
map("n", "<leader>dl", require "dap".run_last)
|
||||
|
||||
on_attach(client, bufnr)
|
||||
end
|
||||
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "scala", "sbt" },
|
||||
callback = function()
|
||||
require "metals".initialize_or_attach(metals_config)
|
||||
end,
|
||||
group = nvim_metals_group,
|
||||
})
|
||||
|
||||
-- Haskell
|
||||
vim.g.haskell_tools = {
|
||||
tools = {
|
||||
log = { level = vim.log.levels.OFF },
|
||||
hover = {
|
||||
border = border,
|
||||
stylize_markdown = true,
|
||||
},
|
||||
},
|
||||
hls = {
|
||||
on_attach = function(client, bufnr)
|
||||
local ht = require "haskell-tools"
|
||||
local opts = { buffer = bufnr }
|
||||
|
||||
map("n", "<leader>hhe", ht.lsp.buf_eval_all, opts)
|
||||
map("n", "<leader>hhs", ht.hoogle.hoogle_signature, opts)
|
||||
map("n", "<leader>hhr", ht.repl.toggle, opts)
|
||||
|
||||
vim.opt_local.shiftwidth = 2
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
default_settings = {
|
||||
haskell = {
|
||||
-- formattingProvider = "fourmolu",
|
||||
formattingProvider = "stylish-haskell",
|
||||
cabalFormattingProvider = "cabal-fmt",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Rust
|
||||
require "rust-tools".setup {
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
cmd = { "rustup", "run", "stable", "rust-analyzer" },
|
||||
},
|
||||
}
|
||||
70
.config/nvim/after/plugin/lualine.lua
Normal file
70
.config/nvim/after/plugin/lualine.lua
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
local function diagnostic_message()
|
||||
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
local ds = vim.diagnostic.get(0, { lnum = row - 1 })
|
||||
if #ds >= 1 then
|
||||
return ds[1].message:gsub("%%", "%%%%");
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local grey = {
|
||||
a = { bg = "#e4e4e5" },
|
||||
b = { bg = "#e4e4e5" },
|
||||
c = { bg = "#e4e4e5" },
|
||||
x = { bg = "#e4e4e5" },
|
||||
y = { bg = "#e4e4e5" },
|
||||
z = { bg = "#e4e4e5" },
|
||||
}
|
||||
|
||||
local curry_theme = {
|
||||
normal = grey,
|
||||
insert = grey,
|
||||
visual = grey,
|
||||
replace = grey,
|
||||
inactive = grey,
|
||||
}
|
||||
|
||||
|
||||
local sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {
|
||||
{
|
||||
"diagnostics",
|
||||
colored = true,
|
||||
symbols = { error = "E", warn = "W", info = "·", hint = "H" },
|
||||
},
|
||||
diagnostic_message,
|
||||
},
|
||||
lualine_c = { "navic" },
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = { "progress", "branch" },
|
||||
}
|
||||
|
||||
require "lualine".setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = curry_theme,
|
||||
component_separators = {},
|
||||
section_separators = {},
|
||||
disabled_filetypes = {
|
||||
statusline = { "fugitive" },
|
||||
winbar = { "fugitive" },
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
},
|
||||
},
|
||||
sections = sections,
|
||||
inactive_sections = sections,
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
}
|
||||
6
.config/nvim/after/plugin/no-neck-pain.lua
Normal file
6
.config/nvim/after/plugin/no-neck-pain.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
require "no-neck-pain".setup {
|
||||
width = 75,
|
||||
buffers = {
|
||||
right = { enabled = false },
|
||||
},
|
||||
}
|
||||
32
.config/nvim/after/plugin/oil.lua
Normal file
32
.config/nvim/after/plugin/oil.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
require "oil".setup {
|
||||
default_file_explorer = false,
|
||||
columns = {
|
||||
"icon",
|
||||
"permissions",
|
||||
-- "size",
|
||||
-- "mtime",
|
||||
},
|
||||
skip_confirm_for_simple_edits = true,
|
||||
prompt_save_on_select_new_entry = false,
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-v>"] = "actions.select_vsplit",
|
||||
["<C-x>"] = "actions.select_split",
|
||||
["<C-t>"] = "actions.select_tab",
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = "actions.close",
|
||||
["<C-l>"] = "actions.refresh",
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = "actions.tcd",
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = "actions.open_external",
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
}
|
||||
46
.config/nvim/after/plugin/telescope.lua
Normal file
46
.config/nvim/after/plugin/telescope.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
local ts = require "telescope"
|
||||
local actions = require "telescope.actions"
|
||||
local themes = require "telescope.themes"
|
||||
local config = require "telescope.config"
|
||||
local builtin = require "telescope.builtin"
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- Clone the default Telescope configuration
|
||||
local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) }
|
||||
|
||||
table.insert(vimgrep_arguments, "--hidden") -- search hidden
|
||||
table.insert(vimgrep_arguments, "--glob") -- ignore git
|
||||
table.insert(vimgrep_arguments, "!**/.git/*")
|
||||
|
||||
ts.setup {
|
||||
defaults = {
|
||||
vimgrep_arguments = vimgrep_arguments,
|
||||
mappings = {
|
||||
i = {
|
||||
["<esc>"] = actions.close,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable telescope fzf native, if installed
|
||||
pcall(require "telescope".load_extension, "fzf")
|
||||
|
||||
|
||||
map("n", "<leader>/",
|
||||
function()
|
||||
builtin.current_buffer_fuzzy_find(themes.get_dropdown { previewer = false })
|
||||
end
|
||||
)
|
||||
map("n", "<leader>sf", builtin.find_files)
|
||||
map("n", "<leader>gf", builtin.git_files)
|
||||
map("n", "<leader>?", builtin.help_tags)
|
||||
map("n", "<leader>sw", builtin.grep_string)
|
||||
map("n", "<leader>sg", builtin.live_grep)
|
||||
map("n", "<leader>sd", builtin.diagnostics)
|
||||
map("n", "<leader>b", builtin.buffers)
|
||||
11
.config/nvim/after/plugin/todo-comments.lua
Normal file
11
.config/nvim/after/plugin/todo-comments.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require "todo-comments".setup {
|
||||
keywords = {
|
||||
FIX = { icon = " ", color = "error", alt = { "FIXME", "BUG", "FIXIT", "ISSUE" } },
|
||||
TODO = { icon = " ", color = "info" },
|
||||
HACK = { icon = "!", color = "warning", alt = { "DEBUG" } },
|
||||
WARN = { icon = "!", color = "warning", alt = { "WARNING", "XXX" } },
|
||||
NOTE = { icon = "·", color = "hint", alt = { "INFO" } },
|
||||
TEST = { icon = "T", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
|
||||
Q = { icon = "?", color = "warning" },
|
||||
},
|
||||
}
|
||||
56
.config/nvim/after/plugin/treesitter.lua
Normal file
56
.config/nvim/after/plugin/treesitter.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
require "nvim-treesitter.configs".setup {
|
||||
|
||||
ensure_installed = {},
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
highlight = { enable = true },
|
||||
|
||||
-- Disable for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- Text objets
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
},
|
||||
selection_modes = {
|
||||
["@parameter.outer"] = "v", -- charwise
|
||||
["@function.outer"] = "V", -- linewise
|
||||
["@class.outer"] = "<c-v>", -- blockwise
|
||||
},
|
||||
include_surrounding_whitespace = true,
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["<leader>a"] = "@parameter.inner",
|
||||
},
|
||||
swap_previous = {
|
||||
["<leader>A"] = "@parameter.inner",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require "treesitter-context".setup {
|
||||
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
|
||||
max_lines = 2, -- How many lines the window should span. Values < = 0 mean no limit.
|
||||
min_window_height = 0, -- Minimum editor window height to enable context. Values < = 0 mean no limit.
|
||||
line_numbers = true,
|
||||
multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line
|
||||
trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
|
||||
mode = "topline", -- Line used to calculate context. Choices: 'cursor', 'topline'
|
||||
zindex = 20, -- The Z-index of the context window
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue