Updated a bunch of stuff in the lua config

This commit is contained in:
Jeremy Wall 2024-01-06 11:06:05 -05:00
parent f7370dffae
commit 234f291d3a
2 changed files with 197 additions and 198 deletions

View File

@ -71,40 +71,40 @@ au BufNewFile,BufRead *.hrl filetype indent off
local cmp = require('cmp') local cmp = require('cmp')
cmp.setup({ cmp.setup({
-- Enable LSP snippets -- Enable LSP snippets
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) vim.fn["vsnip#anonymous"](args.body)
end, end,
}, },
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
['<C-k>'] = cmp.mapping.select_prev_item(), ['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-j>'] = cmp.mapping.select_next_item(), ['<C-j>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<CR>'] = cmp.mapping.confirm { ['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
},
},
-- Installed sources:
sources = cmp.config.sources(
{
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help' }, -- display function signatures with current parameter emphasized
},
{
{ name = 'path' }, -- file paths
},
{
{ name = 'nvim_lua', keyword_length = 2 }, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
}, },
},
-- Installed sources:
sources = cmp.config.sources(
{
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
},
{
{ name = 'path' }, -- file paths
},
{
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
}) })
-- logging -- logging
@ -114,21 +114,21 @@ cmp.setup({
local roslyn_lsp_dll = vim.fs.normalize("~/bin/Microsoft.CodeAnalysis.LanguageServer.dll") local roslyn_lsp_dll = vim.fs.normalize("~/bin/Microsoft.CodeAnalysis.LanguageServer.dll")
local caps = vim.tbl_deep_extend( local caps = vim.tbl_deep_extend(
'force', 'force',
vim.lsp.protocol.make_client_capabilities(), vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities(), require('cmp_nvim_lsp').default_capabilities(),
-- File watching is disabled by default for neovim. -- File watching is disabled by default for neovim.
-- See: https://github.com/neovim/neovim/pull/22405 -- See: https://github.com/neovim/neovim/pull/22405
{ workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }, { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } },
{ window = { progress = false } } { window = { progress = false } }
); );
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
-- Terraform lsp setup -- Terraform lsp setup
lspconfig.terraformls.setup{} lspconfig.terraformls.setup {}
-- Nix language server support -- Nix language server support
lspconfig.nil_ls.setup{ lspconfig.nil_ls.setup {
--single_file_support = true, --single_file_support = true,
--on_attach = function(client, bufnr) --on_attach = function(client, bufnr)
-- -- disable the semanticTokens because it has issues. -- -- disable the semanticTokens because it has issues.
@ -139,11 +139,11 @@ lspconfig.nil_ls.setup{
local vim_pid = vim.fn.getpid() local vim_pid = vim.fn.getpid()
-- "FormatterOptions:EnableEditorConfigSupport=true" -- "FormatterOptions:EnableEditorConfigSupport=true"
local omnisharp_cmd = { 'omnisharp', '--languageserver', '-v', '--hostPID', tostring(vim_pid), } local omnisharp_cmd = { 'omnisharp', '--languageserver', '-v', '--hostPID', tostring(vim_pid), }
local function toSnakeCase(str) local function toSnakeCase(str)
return string.gsub(str, "%s*[- ]%s*", "_") return string.gsub(str, "%s*[- ]%s*", "_")
end end
lspconfig.omnisharp.setup { lspconfig.omnisharp.setup {
@ -153,82 +153,82 @@ lspconfig.omnisharp.setup {
enable_import_completion = true, enable_import_completion = true,
-- Omnisharp has issues with the semanticTokens feature we need to massage it a bit. -- Omnisharp has issues with the semanticTokens feature we need to massage it a bit.
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
-- https://github.com/OmniSharp/omnisharp-roslyn/issues/2483#issuecomment-1492605642 -- https://github.com/OmniSharp/omnisharp-roslyn/issues/2483#issuecomment-1492605642
local tokenModifiers = client.server_capabilities.semanticTokensProvider.legend.tokenModifiers local tokenModifiers = client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
for i, v in ipairs(tokenModifiers) do for i, v in ipairs(tokenModifiers) do
tokenModifiers[i] = toSnakeCase(v) tokenModifiers[i] = toSnakeCase(v)
end end
local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
for i, v in ipairs(tokenTypes) do for i, v in ipairs(tokenTypes) do
tokenTypes[i] = toSnakeCase(v) tokenTypes[i] = toSnakeCase(v)
end end
end, end,
handlers = { handlers = {
["textDocument/definition"] = require('omnisharp_extended').handler, ["textDocument/definition"] = require('omnisharp_extended').handler,
}, },
capabilities = caps, capabilities = caps,
} }
--ocaml --ocaml
lspconfig.ocamllsp.setup{ lspconfig.ocamllsp.setup {
capabilities = caps capabilities = caps
} }
-- Java language server support -- Java language server support
lspconfig.java_language_server.setup{ lspconfig.java_language_server.setup {
capabilities = caps capabilities = caps
} }
-- Typescript language server support -- Typescript language server support
lspconfig.tsserver.setup{ lspconfig.tsserver.setup {
capabilities = caps capabilities = caps
} }
-- Rust language server support -- Rust language server support
lspconfig.rust_analyzer.setup{ lspconfig.rust_analyzer.setup {
capabilities = caps capabilities = caps
} }
-- lua language server setup. -- lua language server setup.
lspconfig.lua_ls.setup{ lspconfig.lua_ls.setup {
settings = { settings = {
Lua = { Lua = {
runtime = { version = 'LuaJIT', }, runtime = { version = 'LuaJIT', },
diagnostics = { diagnostics = {
-- Get the language server to recognize the `vim` global -- Get the language server to recognize the `vim` global
globals = {'vim'}, globals = { 'vim' },
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true), library = vim.api.nvim_get_runtime_file("", true),
-- Disable the checkThirdParty prompts. -- Disable the checkThirdParty prompts.
checkThirdParty = false, checkThirdParty = false,
},
telemetry = {
enable = false,
},
}, },
telemetry = { },
enable = false,
},
},
},
capabilities = caps capabilities = caps
} }
-- lsp configuration -- lsp configuration
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args) callback = function(args)
local opts = { buffer = args.buf } local opts = { buffer = args.buf }
vim.keymap.set("n", '<C-Space>', function() vim.keymap.set("n", '<C-Space>', function()
vim.lsp.buf.hover() vim.lsp.buf.hover()
end, opts) end, opts)
vim.keymap.set({"n", "v"}, "<Leader>a", vim.lsp.buf.code_action, opts) vim.keymap.set({ "n", "v" }, "<Leader>a", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, opts) vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, opts)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.codelens then if client.server_capabilities.codelens then
vim.lsp.codelens.refresh() vim.lsp.codelens.refresh()
end end
end, end,
}) })
vim.api.nvim_create_autocmd({'BufEnter', 'InsertLeave', 'CursorHold'}, { vim.api.nvim_create_autocmd({ 'BufEnter', 'InsertLeave', 'CursorHold' }, {
callback = function(_) callback = function(_)
local clients = vim.lsp.get_active_clients() local clients = vim.lsp.get_active_clients()
for cid = 1, #clients do for cid = 1, #clients do
@ -240,19 +240,19 @@ vim.api.nvim_create_autocmd({'BufEnter', 'InsertLeave', 'CursorHold'}, {
end, end,
}) })
-- LSP Diagnostics Options Setup -- LSP Diagnostics Options Setup
local sign = function(opts) local sign = function(opts)
vim.fn.sign_define(opts.name, { vim.fn.sign_define(opts.name, {
texthl = opts.name, texthl = opts.name,
text = opts.text, text = opts.text,
numhl = '' numhl = ''
}) })
end end
sign({name = 'DiagnosticSignError', text = '🔥'}) sign({ name = 'DiagnosticSignError', text = '🔥' })
sign({name = 'DiagnosticSignWarn', text = '⚠️'}) sign({ name = 'DiagnosticSignWarn', text = '⚠️' })
sign({name = 'DiagnosticSignHint', text = '➡️'}) sign({ name = 'DiagnosticSignHint', text = '➡️' })
sign({name = 'DiagnosticSignInfo', text = '🗒️'}) sign({ name = 'DiagnosticSignInfo', text = '🗒️' })
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = false, virtual_text = false,
@ -280,72 +280,72 @@ autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
-- noselect: Do not select, force to select one from the menu -- noselect: Do not select, force to select one from the menu
-- shortness: avoid showing extra messages when using completion -- shortness: avoid showing extra messages when using completion
-- updatetime: set updatetime for CursorHold -- updatetime: set updatetime for CursorHold
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} vim.opt.completeopt = { 'menuone', 'noselect', 'noinsert' }
vim.opt.shortmess = vim.opt.shortmess + { c = true} vim.opt.shortmess = vim.opt.shortmess + { c = true }
vim.api.nvim_set_option('updatetime', 300) vim.api.nvim_set_option('updatetime', 300)
vim.opt.sessionoptions = {'buffers', 'curdir', 'skiprtp', 'localoptions', 'terminal', 'tabpages' } vim.opt.sessionoptions = { 'buffers', 'curdir', 'skiprtp', 'localoptions', 'terminal', 'tabpages' }
-- Fixed column for diagnostics to appear -- Fixed column for diagnostics to appear
-- Show autodiagnostic popup on cursor hover_range -- Show autodiagnostic popup on cursor hover_range
-- Goto previous / next diagnostic warning / error -- Goto previous / next diagnostic warning / error
-- Show inlay_hints more frequently -- Show inlay_hints more frequently
vim.cmd([[ vim.cmd([[
set signcolumn=yes set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]]) ]])
-- Treesitter Plugin Setup -- Treesitter Plugin Setup
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting=false, additional_vim_regex_highlighting = false,
}, },
--indent = { enable = true }, --indent = { enable = true },
rainbow = { rainbow = {
enable = true, enable = true,
extended_mode = true, extended_mode = true,
max_file_lines = nil, max_file_lines = nil,
}, },
--textobjects = { --textobjects = {
-- enable = true, -- enable = true,
-- select = { -- select = {
-- enable = true, -- enable = true,
-- lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim -- lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
-- keymaps = { -- keymaps = {
-- -- You can use the capture groups defined in textobjects.scm -- -- You can use the capture groups defined in textobjects.scm
-- ['aa'] = '@parameter.outer', -- ['aa'] = '@parameter.outer',
-- ['ia'] = '@parameter.inner', -- ['ia'] = '@parameter.inner',
-- ['af'] = '@function.outer', -- ['af'] = '@function.outer',
-- ['if'] = '@function.inner', -- ['if'] = '@function.inner',
-- ['ac'] = '@class.outer', -- ['ac'] = '@class.outer',
-- ['ic'] = '@class.inner', -- ['ic'] = '@class.inner',
-- }, -- },
-- }, -- },
--}, --},
--incremental_selection = { --incremental_selection = {
-- enable = true, -- enable = true,
-- keymaps = { -- keymaps = {
-- init_selection = '<Leader>c', -- init_selection = '<Leader>c',
-- node_incremental = '<Leader>c', -- node_incremental = '<Leader>c',
-- scope_incremental = '<Leader>ci', -- scope_incremental = '<Leader>ci',
-- node_decremental = '<Leader>cx', -- node_decremental = '<Leader>cx',
-- }, -- },
--}, --},
} }
require'treesitter-context'.setup { require 'treesitter-context'.setup {
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. max_lines = 5, -- 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. min_window_height = 45, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true, line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line 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' trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'. -- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline. -- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil, separator = nil,
zindex = 20, -- The Z-index of the context window zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
} }
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
@ -355,42 +355,42 @@ vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true vim.opt.termguicolors = true
-- setup nvim-tree -- setup nvim-tree
require("nvim-tree").setup{ require("nvim-tree").setup {
hijack_unnamed_buffer_when_opening = true, hijack_unnamed_buffer_when_opening = true,
update_focused_file = { update_focused_file = {
enable = true, enable = true,
}, },
renderer = { renderer = {
icons = { icons = {
show = { show = {
file = false, file = false,
}, },
glyphs = { glyphs = {
default = "-", default = "-",
symlink = "S",
bookmark = "🎗",
modified = "",
folder = {
arrow_closed = "",
arrow_open = "",
default = "📁",
open = "📂",
empty = "📁",
empty_open = "📂",
symlink = "S", symlink = "S",
symlink_open = "S", bookmark = "🎗",
}, modified = "",
git = { folder = {
unstaged = "", arrow_closed = "",
staged = "", arrow_open = "",
unmerged = "", default = "📁",
renamed = "", open = "📂",
untracked = "", empty = "📁",
deleted = "X", empty_open = "📂",
ignored = "", symlink = "S",
}, symlink_open = "S",
},
git = {
unstaged = "",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "X",
ignored = "",
},
}, },
}, },
}, },
diagnostics = { diagnostics = {
enable = true, enable = true,
@ -404,7 +404,7 @@ require("nvim-tree").setup{
}, },
} }
require('trouble').setup{ require('trouble').setup {
icons = false, icons = false,
signs = { signs = {
hint = "➡️", hint = "➡️",
@ -443,7 +443,7 @@ vim.keymap.set("n", "<Leader>mg", function()
vim.cmd("MagitOnly") vim.cmd("MagitOnly")
end) end)
require('possession').setup{ require('possession').setup {
commands = { commands = {
save = 'SSave', save = 'SSave',
load = 'SLoad', load = 'SLoad',
@ -474,16 +474,16 @@ local telescope_builtins = require('telescope.builtin')
local telescope_actions = require('telescope.actions') local telescope_actions = require('telescope.actions')
telescope.load_extension('possession') telescope.load_extension('possession')
-- https://github.com/nvim-telescope/telescope.nvim -- https://github.com/nvim-telescope/telescope.nvim
telescope.setup({ telescope.setup({
defaults = { defaults = {
initial_mode = "normal", initial_mode = "normal",
mappings = { mappings = {
n = { n = {
["<Leader>ql"] = telescope_actions.send_selected_to_qflist + telescope_actions.open_qflist, ["<Leader>ql"] = telescope_actions.send_selected_to_qflist + telescope_actions.open_qflist,
}, },
}, },
}, },
}) })
local harpoon = require('harpoon') local harpoon = require('harpoon')
@ -522,9 +522,9 @@ dap.adapters.lldb = {
} }
dap.adapters.coreclr = { dap.adapters.coreclr = {
type = 'executable', type = 'executable',
command = '/run/current-system/sw/bin/netcoredbg', command = '/run/current-system/sw/bin/netcoredbg',
args = {'--interpreter=vscode'} args = { '--interpreter=vscode' }
} }
dap.configurations.rust = { dap.configurations.rust = {
@ -533,7 +533,7 @@ dap.configurations.rust = {
type = 'lldb', type = 'lldb',
request = 'launch', request = 'launch',
program = function() program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end, end,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
stopOnEntry = false, stopOnEntry = false,
@ -551,4 +551,3 @@ dap.configurations.cs = {
end, end,
}, },
} }

6
nix/darwin/flake.lock generated
View File

@ -36,12 +36,12 @@
}, },
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-cW76KH1n7bNW2wrMQCEg+7eH0lbcMNj+/JBVGG81HlU=", "narHash": "sha256-R0Q8QvXyxzRLuzBKW5ne9/FAFkv1QpMpqL6upo2dTFI=",
"path": "/nix/store/5k2s8xq8c6rd1r4fwc3c1qlva0zns0ky-source/nix/base-system", "path": "/nix/store/an6z19qb3z8nnlzdmnqldilbwdjcypxp-source/nix/base-system",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/nix/store/5k2s8xq8c6rd1r4fwc3c1qlva0zns0ky-source/nix/base-system", "path": "/nix/store/an6z19qb3z8nnlzdmnqldilbwdjcypxp-source/nix/base-system",
"type": "path" "type": "path"
} }
}, },