Add customizations

This commit is contained in:
k-knosala 2024-03-28 21:19:31 +01:00
parent 93fde0556e
commit af39dd4a9f
13 changed files with 151 additions and 28 deletions

View File

@ -0,0 +1 @@
vim.opt_local.wrap = true

10
after/ftplugin/rust.lua Normal file
View File

@ -0,0 +1,10 @@
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set(
"n",
"<leader>a",
function()
vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping
-- or vim.lsp.buf.codeAction() if you don't want grouping.
end,
{ desc = "Rust LSP Code [Action]", silent = true, buffer = bufnr }
)

1
after/ftplugin/typst.lua Normal file
View File

@ -0,0 +1 @@
vim.opt_local.wrap = true

View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.opt`
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
@ -320,6 +320,9 @@ require('lazy').setup({
-- Useful for getting pretty icons, but requires a Nerd Font.
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
--- Get undo history for telescope
'debugloop/telescope-undo.nvim',
},
config = function()
-- Telescope is a fuzzy finder that comes with a lot of different things that
@ -363,6 +366,7 @@ require('lazy').setup({
-- Enable Telescope extensions if they are installed
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
pcall(require('telescope').load_extension, 'undo')
-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
@ -540,7 +544,8 @@ require('lazy').setup({
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
pyright = {},
ruff_lsp = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
@ -565,6 +570,10 @@ require('lazy').setup({
},
},
},
yamlls = { yaml = {} },
typst_lsp = { { filetypes = { 'typst' } } },
jsonls = { { filetypes = { 'json' } } },
taplo = { filetypes = { 'toml' } },
}
-- Ensure the servers and tools above are installed
@ -593,6 +602,8 @@ require('lazy').setup({
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
-- rust_analyzer is set up by rustacevim
['rust_analyzer'] = function() end,
},
}
end,
@ -644,12 +655,12 @@ require('lazy').setup({
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
{
'rafamadriz/friendly-snippets',
config = function()
require('luasnip.loaders.from_vscode').lazy_load()
end,
},
},
},
'saadparwaiz1/cmp_luasnip',
@ -728,22 +739,18 @@ require('lazy').setup({
}
end,
},
{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
--
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
'ellisonleao/gruvbox.nvim',
priority = 1000,
init = function()
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night'
-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
require('gruvbox').setup {
overrides = { SignColumn = { bg = '' } },
}
vim.o.background = 'dark'
vim.cmd.colorscheme 'gruvbox'
end,
},
@ -791,7 +798,7 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
opts = {
ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
ensure_installed = { 'bash', 'c', 'html', 'json', 'lua', 'luadoc', 'markdown', 'python', 'rust', 'toml', 'typst', 'vim', 'vimdoc', 'yaml' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
@ -827,16 +834,16 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.lint',
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
@ -859,5 +866,9 @@ require('lazy').setup({
},
})
-- Import custom settings
require 'custom.init'
require 'custom.keymap'
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et

19
lua/custom/init.lua Normal file
View File

@ -0,0 +1,19 @@
-- Fold code by expression
vim.opt.foldenable = false
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
-- Turn off line wrapping
vim.opt.wrap = false
-- Typst filetype support
vim.filetype.add { extension = { typ = 'typst' } }
-- Reset the cursor after leaving vim. Without this, the cursor changes to a
-- block for the terminal.
vim.cmd [[
augroup RestoreCursorShapeOnExit
autocmd!
autocmd VimLeave * set guicursor=a:ver1
augroup END
]]

25
lua/custom/keymap.lua Normal file
View File

@ -0,0 +1,25 @@
-- Custom keychains
require('which-key').register {
['<leader>p'] = { name = '[P]ython', _ = 'which_key_ignore' },
}
-- Undo
vim.keymap.set("n", "<leader>su", require("telescope").extensions.undo.undo, { desc = '[S]earch [U]ndo' })
-- Lazygit
vim.keymap.set("n", "<leader>gg", ":LazyGit<CR>", { desc = "[G]it Lazy[G]it" })
-- Debug
vim.keymap.set({ "n", "v" }, "<Leader>pm", function() require("dap-python").test_method() end,
{ desc = '[P]ython Debug [M]ethod' })
vim.keymap.set({ "n", "v" }, "<Leader>pc", function() require("dap-python").test_class() end,
{ desc = '[P]ython Debug [C]lass' })
vim.keymap.set("v", "<Leader>k", function() require("dapui").eval() end, { desc = "Debug: Eval" })
-- Navigate buffers
vim.keymap.set("n", "<leader>l", ":ls<CR>:b<space>", { desc = "Select buffer" })
-- Make
vim.keymap.set("n", "<leader>m", ":make <CR>", { desc = "[M]ake" })
-- Telescope undo
vim.keymap.set("n", "<leader>su", require("telescope").extensions.undo.undo, { desc = '[S]earch [U]ndo' })

7
lua/custom/lazygit.lua Normal file
View File

@ -0,0 +1,7 @@
return {
"kdheepak/lazygit.nvim",
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
}
}

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,11 @@
return {
--- File explorer
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
}

View File

@ -0,0 +1,5 @@
return {
'mrcjkb/rustaceanvim',
version = '^4', -- Recommended
ft = { 'rust' },
}

View File

@ -0,0 +1,6 @@
return { require 'lspconfig'.typst_lsp.setup {
settings = {
exportPdf = "never" -- Choose onType, onSave or never.
-- serverPath = "" -- Normally, there is no need to uncomment it.
}
} }

View File

@ -0,0 +1,9 @@
return {
-- Seamless navigation between tmux panes and vim splits
'christoomey/vim-tmux-navigator',
config = function()
-- disable netrw for nvim-tree
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
end,
}

View File

@ -22,7 +22,8 @@ return {
'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here
'leoluz/nvim-dap-go',
-- 'leoluz/nvim-dap-go',
'mfussenegger/nvim-dap-python',
},
config = function()
local dap = require 'dap'
@ -41,7 +42,8 @@ return {
-- 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',
-- 'delve',
'debugpy',
},
}
@ -85,6 +87,7 @@ return {
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Install golang specific config
require('dap-go').setup()
-- require('dap-go').setup()
require('dap-python').setup('~/.local/share/nvim/mason/packages/debugpy/venv/bin/python')
end,
}