Refactoring
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
-- You can add your own plugins here or in other files in this directory!
|
||||
-- I promise not to create any merge conflicts in this directory :)
|
||||
--
|
||||
-- See the kickstart.nvim README for more information
|
||||
return {}
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Formatting
|
||||
require('conform').setup {
|
||||
formatters_by_ft = {
|
||||
elixir = { 'mix' },
|
||||
heex = { 'mix' },
|
||||
go = { 'gofmt' },
|
||||
javascript = { 'prettier' },
|
||||
lua = { 'stylua' },
|
||||
python = { 'black' },
|
||||
rust = { 'rustfmt', lsp_format = 'fallback' },
|
||||
cpp = { 'clang-format' },
|
||||
},
|
||||
format_on_save = {
|
||||
-- These options will be passed to conform.format()
|
||||
timeout_ms = 500,
|
||||
lsp_format = 'fallback',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
vim.g.slime_target = 'tmux'
|
||||
vim.keymap.set('n', '<Space>', '<Plug>SlimeLineSend<CR>')
|
||||
vim.keymap.set('v', '<Space>', "<Plug>SlimeRegionSend<CR>'>")
|
||||
vim.keymap.set('n', '<leader>v', ':SlimeConfig<CR><CR>')
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'python',
|
||||
callback = function()
|
||||
vim.g.slime_python_ipython = 1
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
require('telescope').setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<C-u>'] = false,
|
||||
['<C-d>'] = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, { buffer = bufnr, desc = '[G]oto [D]efinition' })
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,56 @@
|
||||
-- Define a function to highlight the current search term
|
||||
local highlight_search_term = function(label)
|
||||
local search_term = vim.fn.getreg '/'
|
||||
if search_term ~= '' then
|
||||
-- local matches =
|
||||
vim.fn.matchadd(label, search_term)
|
||||
-- for match_id in matches do
|
||||
-- vim.api.nvim_buf_add_highlight(0, -1, label, 0, match_id[1] - 1, match_id[2])
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>m1', function()
|
||||
highlight_search_term 'Matchadd_1'
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>m2', function()
|
||||
highlight_search_term 'Matchadd_2'
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>m3', function()
|
||||
highlight_search_term 'Matchadd_3'
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>m4', function()
|
||||
highlight_search_term 'Matchadd_4'
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>m5', function()
|
||||
highlight_search_term 'Matchadd_5'
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>mc', function()
|
||||
vim.fn.clearmatches()
|
||||
end)
|
||||
|
||||
local colors = {
|
||||
base03 = '#002b36',
|
||||
base02 = '#073642',
|
||||
base01 = '#586e75',
|
||||
base00 = '#657b83',
|
||||
base0 = '#839496',
|
||||
base1 = '#93a1a1',
|
||||
base2 = '#eee8d5',
|
||||
base3 = '#fdf6e3',
|
||||
yellow = '#b58900',
|
||||
orange = '#cb4b16',
|
||||
red = '#dc322f',
|
||||
magenta = '#d33682',
|
||||
violet = '#6c71c4',
|
||||
blue = '#268bd2',
|
||||
cyan = '#2aa198',
|
||||
green = '#859900',
|
||||
}
|
||||
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_1', { bg = colors.blue, fg = 0 })
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_2', { bg = colors.violet, fg = 0 })
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_3', { bg = colors.cyan, fg = 0 })
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_4', { bg = colors.red, fg = 0 })
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_5', { bg = colors.orange, fg = 0 })
|
||||
vim.api.nvim_set_hl(0, 'Matchadd_6', { bg = colors.yellow, fg = 0 })
|
||||
@@ -0,0 +1,10 @@
|
||||
-- require("iroddis.remaps")
|
||||
-- require("iroddis.packer")
|
||||
require 'iroddis.set'
|
||||
require 'iroddis.lazy'
|
||||
require 'iroddis.lsp'
|
||||
require 'iroddis.cmatches'
|
||||
|
||||
require 'iroddis.cfg_conform'
|
||||
require 'iroddis.cfg_slime'
|
||||
require 'iroddis.cfg_telescope'
|
||||
@@ -0,0 +1,48 @@
|
||||
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system {
|
||||
'git',
|
||||
'clone',
|
||||
'--filter=blob:none',
|
||||
'https://github.com/folke/lazy.nvim.git',
|
||||
'--branch=stable', -- latest stable release
|
||||
lazypath,
|
||||
}
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- require 'custom'
|
||||
|
||||
-- [[ Configure plugins ]]
|
||||
require('lazy').setup({
|
||||
-- Git related plugins
|
||||
'junegunn/vim-easy-align', -- Nice alignment
|
||||
'jpalardy/vim-slime', -- Send text from buffer to a tmux pane
|
||||
'neovim/nvim-lspconfig', -- LSP
|
||||
'stevearc/conform.nvim', -- Autoformatting
|
||||
'tanvirtin/monokai.nvim', -- Theme
|
||||
'lewis6991/gitsigns.nvim', -- Nice git annotations
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
-- { 'nvim-mini/mini.nvim', version = '*' },
|
||||
|
||||
{ 'nvim-mini/mini.nvim', version = '*' },
|
||||
-- Fuzzy Finder (files, lsp, etc)
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
version = '*',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
-- optional but recommended
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
||||
},
|
||||
},
|
||||
-- Marks management
|
||||
{
|
||||
'chentoast/marks.nvim',
|
||||
event = 'VeryLazy',
|
||||
opts = {
|
||||
builtin_marks = { '<', '>', '{', '}' },
|
||||
},
|
||||
},
|
||||
}, {})
|
||||
@@ -0,0 +1,44 @@
|
||||
local servers = {}
|
||||
for _, dir in ipairs(vim.api.nvim_get_runtime_file('lsp', true)) do
|
||||
for name, type in vim.fs.dir(dir) do
|
||||
if (type == 'file' or type == 'link') and name:sub(-4) == '.lua' then
|
||||
servers[name:sub(1, -5)] = true -- dedupe across runtimepath entries
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.enable({
|
||||
'ansiblels',
|
||||
'arduino_language_server',
|
||||
'asm_lsp',
|
||||
'ast_grep',
|
||||
'awk_ls',
|
||||
'bashls',
|
||||
'clangd',
|
||||
'cmake',
|
||||
'cssls',
|
||||
'css_variables',
|
||||
'ctags_lsp',
|
||||
'elixirls',
|
||||
'eslint',
|
||||
'fish_lsp',
|
||||
'gleam',
|
||||
'golangci_lint_ls',
|
||||
'gopls',
|
||||
'graphql',
|
||||
'html',
|
||||
'htmx',
|
||||
'janet_lsp',
|
||||
'jsonls',
|
||||
'julials',
|
||||
'just',
|
||||
'lua_ls',
|
||||
'nginx_language_server',
|
||||
'ruff',
|
||||
'rust_analyzer',
|
||||
'systemd_lsp',
|
||||
'tailwindcss',
|
||||
'ty',
|
||||
'vimls',
|
||||
'ziggy'
|
||||
})
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Keymaps for better default experience
|
||||
-- See `:help vim.keymap.set()`
|
||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
||||
|
||||
-- Remap for dealing with word wrap
|
||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
|
||||
vim.keymap.set('n', '<leader>,', ':w!<CR>')
|
||||
vim.keymap.set('n', 'qq', ':qa!<CR>')
|
||||
vim.keymap.set('n', "<leader>'", vim.cmd.tabn)
|
||||
vim.keymap.set('n', '<leader>;', vim.cmd.tabp)
|
||||
vim.keymap.set('n', '<C-e>', ':tabe ')
|
||||
vim.keymap.set('n', '<C-j>', vim.diagnostic.goto_next)
|
||||
vim.keymap.set('n', '<C-k>', vim.diagnostic.goto_prev)
|
||||
vim.keymap.set('n', '<leader>r', ':%s/\\s*$//<CR>')
|
||||
|
||||
-- Moving code!!
|
||||
-- vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
|
||||
-- vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
|
||||
-- vim.keymap.set('x', '<leader>o', '"_dP')
|
||||
|
||||
-- System copy/paste
|
||||
vim.keymap.set('n', '<leader>y', '"+y')
|
||||
vim.keymap.set('v', '<leader>y', '"+y')
|
||||
vim.keymap.set('n', '<leader>y', '"+Y')
|
||||
vim.keymap.set('n', '<leader>Y', ':.w! ~/.vimpaste<CR>')
|
||||
vim.keymap.set('v', '<leader>Y', ':w! ~/.vimpaste<CR>')
|
||||
vim.keymap.set('n', '<leader>P', ':r ~/.vimpaste<CR>')
|
||||
@@ -0,0 +1,65 @@
|
||||
-- [[ NOTE: ]] Must happen before plugins are required (otherwise wrong leader will be used)
|
||||
vim.g.mapleader = ','
|
||||
vim.g.maplocalleader = ','
|
||||
|
||||
vim.opt.autocomplete = true
|
||||
vim.opt.ai = true -- Autoindent
|
||||
vim.opt.updatetime = 50
|
||||
vim.opt.mouse = ''
|
||||
vim.opt.ttimeoutlen = 1000
|
||||
vim.opt.ttimeout = true
|
||||
-- vim.opt.ttimeoutlen = 0 -- Leader timeout (default 50)
|
||||
|
||||
-- Whitespace
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- Search
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Display
|
||||
vim.opt.nu = true
|
||||
vim.opt.wrap = false
|
||||
vim.opt.termguicolors = false
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldmethod = 'expr'
|
||||
vim.opt.wildmode = 'longest:full'
|
||||
|
||||
-- swap
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv 'HOME' .. '/tmp/vim.undo'
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
-- Remove this option if you want your OS clipboard to remain independent.
|
||||
-- See `:help 'clipboard'`
|
||||
-- vim.o.clipboard = 'unnamedplus'
|
||||
|
||||
vim.o.breakindent = true
|
||||
vim.wo.signcolumn = 'yes'
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeoutlen = 300
|
||||
vim.o.completeopt = 'menuone,noselect'
|
||||
vim.o.termguicolors = true
|
||||
-- Because nvim filetypes are stupid ... need to disable formatoptions for all file types
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.opt.formatoptions:remove 'r'
|
||||
vim.opt.formatoptions:remove 'o'
|
||||
end,
|
||||
})
|
||||
|
||||
-- Disable change-detection if in diff mode. Allows for diffs involving redirects
|
||||
-- eg nvim -d <(cmd 1) <(cmd 2)
|
||||
if vim.diff then
|
||||
vim.opt.autoread = false
|
||||
end
|
||||
@@ -1,74 +0,0 @@
|
||||
-- autoformat.lua
|
||||
--
|
||||
-- Use your language server to automatically format your code on save.
|
||||
-- Adds additional commands as well to manage the behavior
|
||||
|
||||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function()
|
||||
-- Switch for controlling whether you want autoformatting.
|
||||
-- Use :KickstartFormatToggle to toggle autoformatting on or off
|
||||
local format_is_enabled = true
|
||||
vim.api.nvim_create_user_command('KickstartFormatToggle', function()
|
||||
format_is_enabled = not format_is_enabled
|
||||
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
|
||||
end, {})
|
||||
|
||||
-- Create an augroup that is used for managing our formatting autocmds.
|
||||
-- We need one augroup per client to make sure that multiple clients
|
||||
-- can attach to the same buffer without interfering with each other.
|
||||
local _augroups = {}
|
||||
local get_augroup = function(client)
|
||||
if not _augroups[client.id] then
|
||||
local group_name = 'kickstart-lsp-format-' .. client.name
|
||||
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
|
||||
_augroups[client.id] = id
|
||||
end
|
||||
|
||||
return _augroups[client.id]
|
||||
end
|
||||
|
||||
-- Whenever an LSP attaches to a buffer, we will run this function.
|
||||
--
|
||||
-- See `:help LspAttach` for more information about this autocmd event.
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
|
||||
-- This is where we attach the autoformatting for reasonable clients
|
||||
callback = function(args)
|
||||
local client_id = args.data.client_id
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
local bufnr = args.buf
|
||||
|
||||
-- Only attach to clients that support document formatting
|
||||
if not client.server_capabilities.documentFormattingProvider then
|
||||
return
|
||||
end
|
||||
|
||||
-- Tsserver usually works poorly. Sorry you work with bad languages
|
||||
-- You can remove this line if you know what you're doing :)
|
||||
if client.name == 'tsserver' then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create an autocmd that will run *before* we save the buffer.
|
||||
-- Run the formatting command for the LSP that has just attached.
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = get_augroup(client),
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
if not format_is_enabled then
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.buf.format {
|
||||
async = false,
|
||||
filter = function(c)
|
||||
return c.id == client.id
|
||||
end,
|
||||
}
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
-- debug.lua
|
||||
--
|
||||
-- Shows how to use the DAP plugin to debug your code.
|
||||
--
|
||||
-- Primarily focused on configuring the debugger for Go, but can
|
||||
-- be extended to other languages as well. That's why it's called
|
||||
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
||||
|
||||
return {
|
||||
-- NOTE: Yes, you can install new plugins here!
|
||||
'mfussenegger/nvim-dap',
|
||||
-- NOTE: And you can specify dependencies as well
|
||||
dependencies = {
|
||||
-- Creates a beautiful debugger UI
|
||||
'rcarriga/nvim-dap-ui',
|
||||
|
||||
-- Installs the debug adapters for you
|
||||
'williamboman/mason.nvim',
|
||||
'jay-babu/mason-nvim-dap.nvim',
|
||||
|
||||
-- Add your own debuggers here
|
||||
'leoluz/nvim-dap-go',
|
||||
},
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
local dapui = require 'dapui'
|
||||
|
||||
require('mason-nvim-dap').setup {
|
||||
-- Makes a best effort to setup the various debuggers with
|
||||
-- reasonable debug configurations
|
||||
automatic_setup = true,
|
||||
|
||||
-- You can provide additional configuration to the handlers,
|
||||
-- see mason-nvim-dap README for more information
|
||||
handlers = {},
|
||||
|
||||
-- You'll need to check that you have the required things installed
|
||||
-- online, please don't ask me how to install them :)
|
||||
ensure_installed = {
|
||||
-- Update this to ensure that you have the debuggers for the langs you want
|
||||
'delve',
|
||||
},
|
||||
}
|
||||
|
||||
-- Basic debugging keymaps, feel free to change to your liking!
|
||||
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
|
||||
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
|
||||
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
|
||||
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
|
||||
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
|
||||
vim.keymap.set('n', '<leader>B', function()
|
||||
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
||||
end, { desc = 'Debug: Set Breakpoint' })
|
||||
|
||||
-- Dap UI setup
|
||||
-- For more information, see |:help nvim-dap-ui|
|
||||
dapui.setup {
|
||||
-- Set icons to characters that are more likely to work in every terminal.
|
||||
-- Feel free to remove or use ones that you like more! :)
|
||||
-- Don't feel like these are good choices.
|
||||
icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = '⏸',
|
||||
play = '▶',
|
||||
step_into = '⏎',
|
||||
step_over = '⏭',
|
||||
step_out = '⏮',
|
||||
step_back = 'b',
|
||||
run_last = '▶▶',
|
||||
terminate = '⏹',
|
||||
disconnect = '⏏',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
|
||||
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
|
||||
|
||||
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||
|
||||
-- Install golang specific config
|
||||
require('dap-go').setup()
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user