initial commit

This commit is contained in:
FredzyW 2024-05-27 16:35:03 +02:00
commit fa147e9042
14 changed files with 440 additions and 0 deletions

5
README.md Normal file
View file

@ -0,0 +1,5 @@
# nvim
Detta är ett repo för att hålla filerna till min NeoVim konfiguration.
Konfigurationen är ganska minimal estetiskt, men har hyfsat mycket funktionalitet.

View file

@ -0,0 +1,18 @@
-- ~/.config/nvim/after/ftplugin/haskell.lua
local ht = require('haskell-tools')
local bufnr = vim.api.nvim_get_current_buf()
local opts = { noremap = true, silent = true, buffer = bufnr, }
-- haskell-language-server relies heavily on codeLenses,
-- so auto-refresh (see advanced configuration) is enabled by default
vim.keymap.set('n', '<Space>cl', vim.lsp.codelens.run, opts)
-- Hoogle search for the type signature of the definition under the cursor
vim.keymap.set('n', '<Space>hs', ht.hoogle.hoogle_signature, opts)
-- Evaluate all code snippets
vim.keymap.set('n', '<Space>ra', ht.lsp.buf_eval_all, opts)
-- Toggle a GHCi repl for the current package
vim.keymap.set('n', '<Space>rr', ht.repl.toggle, opts)
-- Toggle a GHCi repl for the current buffer
vim.keymap.set('n', '<Space>rf', function()
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
end, opts)
vim.keymap.set('n', '<Space>rq', ht.repl.quit, opts)

32
init.lua Normal file
View file

@ -0,0 +1,32 @@
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("lazy").setup("plugins")
-- Keybindsings
require 'keybindings.keymap'
-- Settings
require 'opt.options'
-- Configuration of plugins
require 'plugin.telescope'
require 'plugin.fzf_lsp'
require 'plugin.autoclose'
require 'plugin.lsp_config'
require 'plugin.treesitter'
require 'plugin.dracula'
require 'plugin.cmp'
vim.cmd('colorscheme dracula-soft')

33
lazy-lock.json Normal file
View file

@ -0,0 +1,33 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" },
"LuaSnip-snippets.nvim": { "branch": "main", "commit": "d7e40e4cce622eab2316607dbcd8d6039bcb9fe0" },
"autoclose.nvim": { "branch": "main", "commit": "dc42806540dcf448ecb2bad6b67204410cfbe629" },
"base16-nvim": { "branch": "master", "commit": "b3e9ec6a82c05b562cd71f40fe8964438a9ba64a" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
"friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" },
"fzf": { "branch": "master", "commit": "c30e486b648c1540a660802a5015aeca208274fa" },
"fzf-lsp.nvim": { "branch": "main", "commit": "16905056051759b15a388709a3fa65ff098eb243" },
"haskell-tools.nvim": { "branch": "master", "commit": "217cb7958ebbebf360f7c43efd5129e66d748042" },
"indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" },
"lazy.nvim": { "branch": "main", "commit": "af6afefbb46ab29a8a1db69536b04290a9403876" },
"lazygit.nvim": { "branch": "main", "commit": "0ada6c6e7e138df92f5009b6952f4ac41248305a" },
"leap.nvim": { "branch": "main", "commit": "25753d8a16b69fbbce5d392702c21dbc79d86bd1" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "2b5e9a39b3bf60bfb0cc7c35d5f2e879d4cd72ea" },
"neoconf.nvim": { "branch": "main", "commit": "9a419c4fa772c4c61839a8f7fdd8e863679a8c94" },
"neodev.nvim": { "branch": "main", "commit": "6a533ed9d3435dcaa456380d833ea04da37ea2ed" },
"nvim-cmp": { "branch": "main", "commit": "97dc716fc914c46577a4f254035ebef1aa72558a" },
"nvim-dap": { "branch": "master", "commit": "c1695e500c7d552a0a19953a9aefcc89178fb1af" },
"nvim-lspconfig": { "branch": "master", "commit": "6e5c78ebc9936ca74add66bda22c566f951b6ee5" },
"nvim-treesitter": { "branch": "master", "commit": "1c3fb9eac2a04230e4af23715fa2c190cbeacd70" },
"plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" },
"ripgrep": { "branch": "master", "commit": "3ad0e83471588d8802d5747d0cc9accec76f7ccf" },
"rnvimr": { "branch": "main", "commit": "3c41af742a61caf74a9f83fb82b9ed03ef13b880" },
"sniprun": { "branch": "master", "commit": "97daa506e2faa3939e0491642103635f9d22cd04" },
"substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View file

@ -0,0 +1,72 @@
vim.keymap.set('n', 'z', '<Plug>(leap)')
vim.keymap.set('n', 'Z', '<Plug>(leap-from-window)')
vim.keymap.set({ 'x', 'o' }, 'z', '<Plug>(leap-forward)')
vim.keymap.set({ 'x', 'o' }, 'Z', '<Plug>(leap-backward)')
-- Substitute
vim.keymap.set("n", "s", require('substitute').operator, { noremap = true })
vim.keymap.set("n", "ss", require('substitute').line, { noremap = true })
vim.keymap.set("n", "S", require('substitute').eol, { noremap = true })
vim.keymap.set("x", "s", require('substitute').visual, { noremap = true })
-- Move commands
vim.keymap.set('n', '<Super-j>', ':MoveLine(1)<CR>', opts)
vim.keymap.set('n', '<Super-k>', ':MoveLine(-1)<CR>', opts)
vim.keymap.set('v', '<Super-j>', ':MoveBlock(1)<CR>', opts)
vim.keymap.set('v', '<Super-k>', ':MoveBlock(-1)<CR>', opts)
-- Good navigation mappings for wrap
vim.api.nvim_set_keymap('n', 'j', 'gj', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'k', 'gk', { noremap = true, silent = true })
-- Buffer navigation
vim.api.nvim_set_keymap('n', '<Tab>', ':bnext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-Tab>', ':bprevious<CR>', { noremap = true, silent = true })
-- Window navigation
vim.api.nvim_set_keymap('n', '<C-k>', ':wincmd k<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-j>', ':wincmd j<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-h>', ':wincmd h<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-l>', ':wincmd l<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<Space>c', ':bd<CR>', { silent = true })
-- Sniprun
vim.api.nvim_set_keymap('v', 'f', '<Plug>SnipRun', { silent = true })
vim.api.nvim_set_keymap('n', '<leader>f', '<Plug>SnipRunOperator', { silent = true })
vim.api.nvim_set_keymap('n', '<leader>ff', '<Plug>SnipRun', { silent = true })
-- Highlight yanked
vim.api.nvim_create_autocmd('TextYankPost', {
group = vim.api.nvim_create_augroup('highlight_yank', {}),
desc = 'Hightlight selection on yank',
pattern = '*',
callback = function()
vim.highlight.on_yank { higroup = 'IncSearch', timeout = 200 }
end,
})
-- Telescope bindings
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<Space>f', builtin.find_files, {})
vim.keymap.set('n', '<Space>o', builtin.live_grep, {})
vim.keymap.set('n', '<Space>b', builtin.buffers, {})
-- Bindings for save and quit
vim.api.nvim_set_keymap('n', '<Space>w', ':w<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<Space>q', ':q<CR>', {})
-- Neotree bindings
vim.api.nvim_set_keymap('n', '<Space>e', ':RnvimrToggle<CR>', { noremap = true, silent = true })
vim.api.nvim_set_var('rnvimr_enable_ex', 1)
vim.api.nvim_set_var('rnvimr_hidden_filter', "")
vim.api.nvim_set_var('rnvimr_enable_picker', 1)
vim.api.nvim_set_var('rnvimr_edit_cmd', 'drop')
vim.api.nvim_set_var('rnvimr_draw_border', 0)
vim.api.nvim_set_var('rnvimr_hide_gitignore', 0)
vim.api.nvim_set_var('rnvimr_border_attr', {fg = 14, bg = -1})
vim.api.nvim_set_var('rnvimr_enable_bw', 1)
vim.api.nvim_set_var('rnvimr_shadow_winblend', 70)
vim.api.nvim_set_var('rnvimr_ranger_cmd', {'ranger', '--cmd=set draw_borders both'})

9
lua/opt/options.lua Normal file
View file

@ -0,0 +1,9 @@
vim.opt.wrap = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.o.termguicolors = true
vim.wo.relativenumber = true
vim.wo.number = true
vim.g.mapleader = ' '
vim.o.cmdheight = 0

7
lua/plugin/autoclose.lua Normal file
View file

@ -0,0 +1,7 @@
require("autoclose").setup({
keys = {
["$"] = { escape = true, close = true, pair = "$$", disabled_filetypes = { "haskell", "bash", "php" } },
["'"] = { escape = true, close = true, pair = "''", disabled_filetypes = { "markdown" } },
["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = { "markdown" } },
},
})

34
lua/plugin/cmp.lua Normal file
View file

@ -0,0 +1,34 @@
local cmp = require('cmp')
cmp.setup({
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<C-e>'] = cmp.mapping.abort(),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = 'select' }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = 'select' }),
['<Tab>'] = cmp.mapping.select_next_item({ behavior = 'select' }),
['<C-p>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item({ behavior = 'insert' })
else
cmp.complete()
end
end),
['<C-n>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_next_item({ behavior = 'insert' })
else
cmp.complete()
end
end),
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
})

40
lua/plugin/dracula.lua Normal file
View file

@ -0,0 +1,40 @@
local dracula = require("dracula")
dracula.setup({
-- customize dracula color palette
colors = {
bg = "#282A36",
fg = "#F8F8F2",
selection = "#44475A",
comment = "#6272A4",
red = "#FF5555",
orange = "#FFB86C",
yellow = "#F1FA8C",
green = "#50fa7b",
purple = "#BD93F9",
cyan = "#8BE9FD",
pink = "#FF79C6",
bright_red = "#FF6E6E",
bright_green = "#69FF94",
bright_yellow = "#FFFFA5",
bright_blue = "#D6ACFF",
bright_magenta = "#FF92DF",
bright_cyan = "#A4FFFF",
bright_white = "#FFFFFF",
menu = "#21222C",
visual = "#3E4452",
gutter_fg = "#4B5263",
nontext = "#3B4048",
white = "#ABB2BF",
black = "#191A21",
},
-- show the '~' characters after the end of buffers
show_end_of_buffer = false, -- default false
-- use transparent background
transparent_bg = false, -- default false
-- set custom lualine background color
lualine_bg_color = "#FFFFFF", -- default nil
-- set italic comment
italic_comment = true, -- default false
-- overrides the default highlights with table see `:h synIDattr`
overrides = {},
})

1
lua/plugin/fzf_lsp.lua Normal file
View file

@ -0,0 +1 @@
require'fzf_lsp'.setup()

34
lua/plugin/lsp_config.lua Normal file
View file

@ -0,0 +1,34 @@
-- LSP Setup
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({ buffer = bufnr })
end)
require 'lspconfig'.hls.setup {}
require 'lspconfig'.omnisharp.setup {
cmd = { "/home/fw/.nix-profile/bin/dotnet", "/home/fw/.local/share/lvim/mason/packages/omnisharp/libexec/OmniSharp.dll" },
}
require 'lspconfig'.clojure_lsp.setup {}
require 'lspconfig'.nil_ls.setup {}
require 'lspconfig'.marksman.setup {}
require 'lspconfig'.pylsp.setup {}
require 'lspconfig'.bashls.setup {}
require 'lspconfig'.dockerls.setup {}
require 'lspconfig'.docker_compose_language_service.setup {}
require 'lspconfig'.ansiblels.setup {}
require 'lspconfig'.yamlls.setup {}
require 'lspconfig'.lua_ls.setup {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
}
}
require'lspconfig'.vls.setup{}
require'lspconfig'.volar.setup{
filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'}
}
require'lspconfig'.vuels.setup{}
require'lspconfig'.jsonls.setup{}

19
lua/plugin/telescope.lua Normal file
View file

@ -0,0 +1,19 @@
local telescope = require('telescope')
telescope.setup {
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
}
},
pickers = {
find_files = {
hidden = true
}
}
}

34
lua/plugin/treesitter.lua Normal file
View file

@ -0,0 +1,34 @@
require 'nvim-treesitter'.setup()
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.csharp = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-c-sharp", -- local path or git repo
files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc
branch = "master", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "cs", -- if filetype does not match the parser name
}
require'nvim-treesitter.configs'.setup {
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "haskell", "python", "bash", "clojure", "nix", "dockerfile", "latex", "csharp", "markdown", "json", "vue", "typescript" },
sync_install = false,
auto_install = true,
ignore_install = { "javascript" },
highlight = {
enable = true,
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = false,
},
}

102
lua/plugins.lua Normal file
View file

@ -0,0 +1,102 @@
return {
{
'm4xshen/autoclose.nvim',
},
{
"Mofiqul/dracula.nvim"
},
{
"BurntSushi/ripgrep",
},
{
'kevinhwang91/rnvimr',
},
{
'ggandor/leap.nvim',
},
{
'gfanto/fzf-lsp.nvim',
},
{
"folke/which-key.nvim",
},
{
"folke/neodev.nvim",
},
{
"mfussenegger/nvim-dap",
},
{
'neovim/nvim-lspconfig'
},
{
'hrsh7th/cmp-nvim-lsp'
},
{
'hrsh7th/nvim-cmp'
},
{
"folke/neoconf.nvim",
cmd = "Neoconf"
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {}
},
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x'
},
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
},
{ "junegunn/fzf" },
{
"L3MON4D3/LuaSnip",
version = "v2.*",
dependencies = {
"rafamadriz/friendly-snippets",
"molleweide/LuaSnip-snippets.nvim",
"saadparwaiz1/cmp_luasnip"
},
build = "make install_jsregexp"
},
{
"gbprod/substitute.nvim",
opts = {}
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate"
},
{
'nvim-telescope/telescope.nvim',
tag = '0.1.6',
dependencies = {
'nvim-lua/plenary.nvim'
}
},
{
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
dependencies = {
"nvim-lua/plenary.nvim",
},
keys = {
{ "<leader>gg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
}
},
{
'numToStr/Comment.nvim',
opts = {},
lazy = false,
},
}