add nvim config

This commit is contained in:
Adam Jeniski 2023-01-07 14:44:09 -05:00
parent a9ab9b2822
commit ccf10b2b40
6 changed files with 446 additions and 0 deletions

View File

@ -0,0 +1 @@
vim.g['conjure#extract#tree_sitter#enabled'] = true

View File

@ -0,0 +1,54 @@
require('lualine').setup {
options = {
theme = 'modus-vivendi', -- https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md
component_separators = '|',
section_separators = { left = '', right = '' },
},
sections = {
lualine_a = {
-- { 'mode', separator = { left = '' }, right_padding = 2 },
'mode'
},
lualine_b = {{ 'filename', path = 1 }, 'branch', 'diff', 'diagnostics' },
lualine_c = {'searchcount'},
lualine_x = {},
lualine_y = {'fileformat', { 'filetype', colored = true, icon_only = true, padding = { left = 1, right = 2 }}},
lualine_z = {
-- { 'location', separator = { right = '' }, left_padding = 2 },
'progress'
},
},
inactive_sections = {
lualine_a = { {'filename', path = 1} },
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {'progress'},
},
tabline = {
lualine_a = {'buffers'},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {'tabs'},
},
winbar = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
inactive_winbar = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
extensions = {'quickfix'},
}

View File

@ -0,0 +1,210 @@
local opts = {
tools = { -- rust-tools options
-- how to execute terminal commands
-- options right now: termopen / quickfix
executor = require("rust-tools.executors").termopen,
runnables = {
use_telescope = true
},
-- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
on_initialized = nil,
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
reload_workspace_from_cargo_toml = true,
-- These apply to the default RustSetInlayHints command
inlay_hints = {
-- automatically set inlay hints (type hints)
-- default: true
auto = true,
-- Only show inlay hints for the current line
only_current_line = false,
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
-- prefix for parameter hints
-- default: "<-"
parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining)
-- default: "=>"
other_hints_prefix = "=> ",
-- whether to align to the length of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 7,
-- The color of the hints
highlight = "Comment",
},
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
hover_actions = {
-- the border that is used for the hover window
-- see vim.api.nvim_open_win()
border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
},
-- Maximal width of the hover window. Nil means no max.
max_width = nil,
-- Maximal height of the hover window. Nil means no max.
max_height = nil,
-- whether the hover action window gets automatically focused
-- default: false
auto_focus = false,
},
-- settings for showing the crate graph based on graphviz and the dot
-- command
crate_graph = {
-- Backend used for displaying the graph
-- see: https://graphviz.org/docs/outputs/
-- default: x11
backend = "x11",
-- where to store the output, nil for no output stored (relative
-- path from pwd)
-- default: nil
output = nil,
-- true for all crates.io and external crates, false only the local
-- crates
-- default: true
full = true,
-- List of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion
-- Last updated: 2021-08-26
enabled_graphviz_backends = {
"bmp",
"cgimage",
"canon",
"dot",
"gv",
"xdot",
"xdot1.2",
"xdot1.4",
"eps",
"exr",
"fig",
"gd",
"gd2",
"gif",
"gtk",
"ico",
"cmap",
"ismap",
"imap",
"cmapx",
"imap_np",
"cmapx_np",
"jpg",
"jpeg",
"jpe",
"jp2",
"json",
"json0",
"dot_json",
"xdot_json",
"pdf",
"pic",
"pct",
"pict",
"plain",
"plain-ext",
"png",
"pov",
"ps",
"ps2",
"psd",
"sgi",
"svg",
"svgz",
"tga",
"tiff",
"tif",
"tk",
"vml",
"vmlz",
"wbmp",
"webp",
"xlib",
"x11",
},
},
},
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- standalone file support
-- setting it to false may improve startup time
standalone = true,
on_attach = function(_, buffnr)
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_option(buffnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = buffnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, { silent = true, buffer = buffnr })
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>F', vim.lsp.buf.formatting, bufopts)
vim.keymap.set('n', '<leader>ca', ':RustCodeAction<cr>', bufopts)
vim.keymap.set('n', '<leader>K', ':RustHoverActions<cr>', bufopts)
vim.keymap.set('n', '<leader>R', ':RustRunnables<cr>', bufopts)
vim.keymap.set('n', '<leader>D', ':RustDebuggables<cr>', bufopts)
end,
}, -- rust-analyzer options
-- debugging stuff
dap = {
adapter = {
type = "executable",
command = "lldb-vscode",
name = "rt_lldb",
},
},
}
require('rust-tools').setup(opts)

View File

@ -0,0 +1 @@
require("scrollbar").setup()

View File

@ -0,0 +1,106 @@
local lib = require("nvim-tree.lib")
local view = require("nvim-tree.view")
local git_add = function()
local node = lib.get_node_at_cursor()
local gs = node.git_status
-- If the file is untracked, unstaged or partially staged, we stage it
if gs == "??" or gs == "MM" or gs == "AM" or gs == " M" then
vim.cmd("silent !git add " .. node.absolute_path)
-- If the file is staged, we unstage
elseif gs == "M " or gs == "A " then
vim.cmd("silent !git restore --staged " .. node.absolute_path)
end
lib.refresh_tree()
end
local function collapse_all()
require("nvim-tree.actions.tree-modifiers.collapse-all").fn()
end
local function edit_or_open()
-- open as vsplit on current node
local action = "edit"
local node = lib.get_node_at_cursor()
-- Just copy what's done normally with vsplit
if node.link_to and not node.nodes then
require('nvim-tree.actions.node.open-file').fn(action, node.link_to)
view.close() -- Close the tree if file was opened
elseif node.nodes ~= nil then
lib.expand_or_collapse(node)
else
require('nvim-tree.actions.node.open-file').fn(action, node.absolute_path)
view.close() -- Close the tree if file was opened
end
end
local function vsplit_preview()
-- open as vsplit on current node
local action = "vsplit"
local node = lib.get_node_at_cursor()
-- Just copy what's done normally with vsplit
if node.link_to and not node.nodes then
require('nvim-tree.actions.node.open-file').fn(action, node.link_to)
elseif node.nodes ~= nil then
lib.expand_or_collapse(node)
else
require('nvim-tree.actions.node.open-file').fn(action, node.absolute_path)
end
-- Finally refocus on tree if it was lost
view.focus()
end
local function hsplit_preview()
-- open as hsplit on current node
local action = "hsplit"
local node = lib.get_node_at_cursor()
-- Just copy what's done normally with vsplit
if node.link_to and not node.nodes then
require('nvim-tree.actions.node.open-file').fn(action, node.link_to)
elseif node.nodes ~= nil then
lib.expand_or_collapse(node)
else
require('nvim-tree.actions.node.open-file').fn(action, node.absolute_path)
end
-- Finally refocus on tree if it was lost
view.focus()
end
require("nvim-tree").setup({
view = {
mappings = {
custom_only = false,
list = {
{ key = "l", action = "edit", action_cb = edit_or_open },
{ key = "L", action = "vsplit_preview", action_cb = vsplit_preview },
{ key = "S", action = "hsplit_preview", action_cb = hsplit_preview },
{ key = "h", action = "close_node" },
{ key = "H", action = "collapse_all", action_cb = collapse_all },
{ key = "ga", action = "git_add", action_cb = git_add },
}
},
},
actions = {
open_file = {
quit_on_open = false
}
}
})
vim.api.nvim_set_keymap("n", "<C-h>", ":NvimTreeToggle<cr>", { silent = true, noremap = true })

View File

@ -0,0 +1,74 @@
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(_, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, { silent = true, buffer = bufnr })
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>F', vim.lsp.buf.formatting, bufopts)
end
require('rust-tools').setup({
tools = { -- rust-tools options
executor = require("rust-tools/executors").termopen,
on_initialized = nil,
reload_workspace_from_cargo_toml = true,
autoSetHints = true,
hover_with_actions = false,
hover_actions = {
border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
},
auto_focus = true,
},
inlay_hints = {
show_parameter_hints = true,
parameter_hints_prefix = "<- ",
other_hints_prefix = "=> ",
current_line_only = false,
}
},
server = {
on_attach = function(_, buffnr)
on_attach(_, buffnr)
local bufopts = { silent = true, buffer = buffnr }
vim.keymap.set('n', '<leader>ca', ':RustCodeAction<cr>', bufopts)
vim.keymap.set('n', '<leader>K', ':RustHoverActions<cr>', bufopts)
vim.keymap.set('n', '<leader>R', ':RustRunnables<cr>', bufopts)
vim.keymap.set('n', '<leader>D', ':RustDebuggables<cr>', bufopts)
end,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy"
}
}
}
},
dap = {
--adapter = require('rust-tools.dap').get_codelldb_adapter(codelldb_path, liblldb_path)
}
})