Adds my basic setup

This commit is contained in:
zwergius 2024-01-12 17:23:52 +01:00
parent 9b256d9368
commit fd947ffd03
7 changed files with 203 additions and 11 deletions

11
auto-mkdir.vim Normal file
View File

@ -0,0 +1,11 @@
augroup vimrc-auto-mkdir
autocmd!
autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang)
function! s:auto_mkdir(dir, force)
if !isdirectory(a:dir)
\ && (a:force
\ || input("'" . a:dir . "' does not exist. Create? [y/N]") =~? '^y\%[es]$')
call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
endif
endfunction
augroup END

View File

@ -152,10 +152,11 @@ require('lazy').setup({
{
-- Theme inspired by Atom
'navarasu/onedark.nvim',
-- 'navarasu/onedark.nvim',
'rmehri01/onenord.nvim',
priority = 1000,
config = function()
vim.cmd.colorscheme 'onedark'
vim.cmd.colorscheme 'onenord'
end,
},
@ -166,10 +167,17 @@ require('lazy').setup({
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
theme = 'onenord',
component_separators = '|',
section_separators = '',
},
sections = {
lualine_c = {
{
'filename', path = 4
}
}
}
},
},
@ -218,8 +226,8 @@ require('lazy').setup({
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
-- require 'kickstart.plugins.autoformat',
-- require 'kickstart.plugins.debug',
require 'kickstart.plugins.autoformat',
require 'kickstart.plugins.debug',
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
@ -227,15 +235,27 @@ require('lazy').setup({
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
--
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}, {})
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- Line & relative line numbers
vim.opt.number = true
vim.opt.relativenumber = true
-- Indents
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.smartindent = true
-- Set highlight on search
vim.o.hlsearch = false
vim.opt.incsearch = true
-- Make line numbers default
vim.wo.number = true
@ -271,12 +291,29 @@ vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- Filetype overrides
vim.filetype.add({
extension = {
postcss = 'css',
}
})
-- [[ Basic Keymaps ]]
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Easy save with CTRL + s
vim.keymap.set('n', '<C-s>', ':update<cr>', { noremap = true })
vim.keymap.set({ 'i', 'v' }, '<C-s>', '<Esc>:update<cr>', { noremap = true })
-- Split Movement
vim.keymap.set('n', '<C-h>', '<C-w>h', { noremap = true, silent = true })
vim.keymap.set('n', '<C-j>', '<C-w>j', { noremap = true, silent = true })
vim.keymap.set('n', '<C-k>', '<C-w>k', { noremap = true, silent = true })
vim.keymap.set('n', '<C-l>', '<C-w>l', { noremap = true, 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 })
@ -297,9 +334,19 @@ vim.api.nvim_create_autocmd('TextYankPost', {
require('telescope').setup {
defaults = {
mappings = {
-- for input mode
i = {
['<C-u>'] = false,
['<C-d>'] = false,
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
["<C-n>"] = require('telescope.actions').cycle_history_next,
["<C-p>"] = require('telescope.actions').cycle_history_prev,
},
-- for normal mode
n = {
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
},
},
},
@ -333,7 +380,18 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
vim.defer_fn(function()
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },
ensure_installed = {
"bash",
"javascript",
"json",
"lua",
"typescript",
"tsx",
"css",
"rust",
"yaml",
"svelte",
},
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
@ -399,8 +457,8 @@ end, 0)
-- 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>do', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>dd', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
@ -478,7 +536,9 @@ local servers = {
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
-- prettierd = {
-- },
--
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
@ -562,3 +622,6 @@ cmp.setup {
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- Autocommand create folder(s) for new file
vim.cmd 'source ~/.config/nvim/auto-mkdir.vim'

36
lazy-lock.json Normal file
View File

@ -0,0 +1,36 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "0df29db3543837f8b41597f2640397c5ec792b7b" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "2c1e852fbf723b7d89b14fd28089472d92edeeb9" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"gitsigns.nvim": { "branch": "main", "commit": "ff01d34daaed72f271a8ffa088a7e839a60c640f" },
"indent-blankline.nvim": { "branch": "master", "commit": "0ac5dfe835ec0f201ef6af17d4737d43b4bfce0d" },
"lazy.nvim": { "branch": "main", "commit": "ed6c9ffe2174bcfe4c17199ec4535aa4d4be1e62" },
"lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e7b64c11035aa924f87385b72145e0ccf68a7e0a" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "6148b51db945b55b3b725da39eaea6441e59dff8" },
"mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" },
"neo-tree.nvim": { "branch": "main", "commit": "6f8c49956c89e9fefae6acdfe1d57c6293b0a03d" },
"neodev.nvim": { "branch": "main", "commit": "24b403eabde652904077f84fd55441744e77a109" },
"nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" },
"nvim-autopairs": { "branch": "master", "commit": "f6c71641f6f183427a651c0ce4ba3fb89404fa9e" },
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
"nvim-dap": { "branch": "master", "commit": "92dc531eea2c9a3ef504a5c8ac0decd1fa59a6a3" },
"nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" },
"nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" },
"nvim-lspconfig": { "branch": "master", "commit": "e49b1e90c1781ce372013de3fa93a91ea29fc34a" },
"nvim-treesitter": { "branch": "master", "commit": "49e71322db582147ce8f4df1853d9dab08da0826" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "78c49ca7d2f7ccba2115c11422c037713c978ad1" },
"nvim-web-devicons": { "branch": "master", "commit": "3af745113ea537f58c4b1573b64a429fefad9e07" },
"onenord.nvim": { "branch": "main", "commit": "3679fb93aaf473c1dd63222ac88577a909f6b41c" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
"vim-fugitive": { "branch": "master", "commit": "cbe9dfa162c178946afa689dd3f42d4ea8bf89c1" },
"vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"which-key.nvim": { "branch": "main", "commit": "6962dae3565369363b59dd51fb206051555fcb4d" }
}

View File

@ -0,0 +1,15 @@
return {
"windwp/nvim-autopairs",
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require("nvim-autopairs").setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
end,
}

View File

@ -0,0 +1,3 @@
return {
"nvim-tree/nvim-web-devicons", lazy = true
}

View File

@ -0,0 +1,26 @@
return {
"nvim-neo-tree/neo-tree.nvim",
version = "*",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
config = function()
require('neo-tree').setup {
filesystem = {
filtered_items = {
visible = true,
hide_dotfiles = false,
hide_gitignored = true,
hide_by_name = {
-- '.git',
-- '.DS_Store',
-- 'thumbs.db',
}
}
}
}
vim.keymap.set('n', '<leader>e', '<Cmd>Neotree toggle<CR>', { desc = 'Open filetree explorer' })
end,
}

View File

@ -0,0 +1,38 @@
return {
"stevearc/conform.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" }, -- to disable comment this out
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
css = { { --[[ "prettierd", ]] "prettier" } },
graphql = { { --[[ "prettierd", ]] "prettier" } },
html = { { --[[ "prettierd", ]] "prettier" } },
javascript = { { --[[ "prettierd", ]] "prettier" } },
javascriptreact = { { --[[ "prettierd", ]] "prettier" } },
json = { { --[[ "prettierd", ]] "prettier" } },
less = { { --[[ "prettierd", ]] "prettier" } },
markdown = { { --[[ "prettierd", ]] "prettier" } },
scss = { { --[[ "prettierd", ]] "prettier" } },
svelte = { { --[[ "prettierd", ]] "prettier" } },
typescript = { { --[[ "prettierd", ]] "prettier" } },
typescriptreact = { { --[[ "prettierd", ]] "prettier" } },
yaml = { { --[[ "prettierd", ]] "prettier" } },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500
}
})
vim.keymap.set({ "n", "v" }, "<leader>f", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
})
end, { desc = "Format file or range (in visual mode)" })
end
}