diff options
Diffstat (limited to 'artix/home/.config/nvim/init.lua')
| -rw-r--r-- | artix/home/.config/nvim/init.lua | 254 |
1 files changed, 254 insertions, 0 deletions
diff --git a/artix/home/.config/nvim/init.lua b/artix/home/.config/nvim/init.lua new file mode 100644 index 0000000..71bedac --- /dev/null +++ b/artix/home/.config/nvim/init.lua @@ -0,0 +1,254 @@ +vim.g.mapleader = " " + +vim.o.number = true +vim.o.relativenumber = true + +vim.o.undofile = true +vim.o.ignorecase = true + +vim.o.expandtab = false +vim.o.shiftwidth = 8 +vim.o.tabstop = 8 +vim.o.softtabstop = 8 +vim.o.smartindent = true +vim.o.autoindent = true + +vim.o.termguicolors = true +vim.o.signcolumn = "yes" +vim.o.winborder = 'single' +vim.o.showmode = true +vim.o.guicursor = "" + +vim.o.swapfile = false + +vim.o.list = true +vim.o.cursorline = true + +-- •⏎.·○◦ +vim.o.listchars = "tab:🡪 ,trail:·,eol:⏎,space:·,multispace:·,lead:·,leadmultispace:·" + +vim.o.completeopt = "fuzzy,menuone,noselect" +vim.diagnostic.config({ virtual_text = true }) + +-- FRENCH SPELLS + +local spell_path = vim.fn.stdpath("data") .. "/site/spell" +if not (vim.uv.fs_stat(spell_path .. "/fr.utf-8.spl") and vim.uv.fs_stat(spell_path .. "/fr.utf-8.sug")) then + print("Installing french spells") + -- Other mirrors can be found on https://www.vim.org/mirrors.php + local mirror = "https://vim.mirror.garr.it/pub/vim/" .. "runtime/spell/" + local files = { "fr.utf-8.spl", "fr.utf-8.sug" } + vim.fn.mkdir(spell_path, "p") + for _, file in ipairs(files) do + vim.fn.system(string.format("curl -L %s%s -o %s/%s", mirror, file, spell_path, file)) + end +end + +vim.cmd [[set spelllang=en,fr]] +vim.cmd [[set spell]] + +-- PLUGINS + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.uv.fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + "neovim/nvim-lspconfig", + "ibhagwan/fzf-lua", + "nvim-tree/nvim-web-devicons", + "mfussenegger/nvim-jdtls", + "mfussenegger/nvim-dap", + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = { + style = "night", + transparent = true, + styles = { + comments = { italic = true, bold = false }, + keywords = { italic = true, bold = false }, + functions = { italic = true, bold = false }, + variables = { italic = false, bold = false }, + sidebars = "dark", + floats = "dark", + }, + dim_inactive = false, + + on_colors = function(colors) end, + on_highlights = function(highlights, colors) end, + cache = true, + }, + }, + { "lewis6991/gitsigns.nvim", opts = {} }, + { "windwp/nvim-autopairs", opts = {} }, + { + "saghen/blink.cmp", + opts = { + keymap = { preset = 'enter' }, + fuzzy = { implementation = "rust" } + } + }, + { + "stevearc/oil.nvim", + opts = { + default_file_explorer = true, + lsp_file_methods = { + enabled = true, + timeout_ms = 1000, + autosave_changes = true, + }, + columns = { + "permissions", + "size", + "icon", + }, + float = { + max_width = 0.7, + max_height = 0.6, + border = vim.o.winborder, + }, + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + view_options = { + show_hidden = true, + }, + } + }, + { + "sphamba/smear-cursor.nvim", + opts = { + smear_insert_mode = true, + stiffness = 0.7, + trailing_stiffness = 0.3, + stiffness_insert_mode = 0.7, + trailing_stiffness_insert_mode = 0.7, + damping = 0.67, + damping_insert_mode = 0.67, + distance_stop_animating = 0.4, + }, + }, + { + "nvim-neo-tree/neo-tree.nvim", + opts = {}, + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + }, + lazy = false + } + } +}) + +vim.cmd [[colorscheme tokyonight-night]] +vim.cmd [[Gitsigns toggle_current_line_blame]] + +-- MAPPING + +local map = vim.keymap.set + +map("n", "<C-d>", "<C-d>zz") +map("n", "<C-u>", "<C-u>zz") +map("v", "J", ":m '>+1<CR>gv=gv") +map("v", "K", ":m '<-2<CR>gv=gv") +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") +map("n", "<leader>s", [[%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) +map("n", "<leader>e", [[:Oil<CR>]]) + +local fzf = require("fzf-lua") -- blazing fast + +map("n", "<leader>F", ":FzfLua<CR>") +map("n", "<leader>f", fzf.files) +map("n", "<leader>t", fzf.treesitter) +map("n", "<leader>/", fzf.live_grep) + +-- Configure lua_ls to use neovim runtime or all of lua_ls lib. +-- We put way much load on the cpu if we open both. +local lua_ls_lib = {} +local neovim_config_path = vim.fn.expand("~/code/dox/artixlinux/home/.config/nvim/init.lua") + +if vim.api.nvim_buf_get_name(0) == neovim_config_path then + lua_ls_lib = vim.api.nvim_get_runtime_file("", true) +else + for lib in vim.fn.expand("/usr/lib/lua-language-server/meta/3rd/*/library"):gmatch("[^\n]+") do + table.insert(lua_ls_lib, lib) + end +end + +vim.lsp.config("lua_ls", { + settings = { + Lua = { + workspace = { + library = lua_ls_lib + } + } + } +}) + +-- do not enable jdtls here, we let the nvim-jdtls plugin do everything +vim.lsp.enable({ + "lua_ls", "cssls", "html", "jsonls", "clangd", "ts_ls", + "tinymist", "marksman", "lemminx", "rust_analyzer", "pyright" +}) + +-- AUTOCMDS + +vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() vim.hl.on_yank() end +}) + +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() vim.lsp.buf.format() end +}) + +vim.api.nvim_create_autocmd("BufWritePost", { + pattern = "*.tex", + callback = function() vim.cmd [[! pdflatex % ]] end +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "java", + callback = function(args) + local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") + local workspace_dir = vim.fn.stdpath("data") + .. package.config:sub(1, 1) + .. "jdtls-workspace" + .. package.config:sub(1, 1) + .. project_name + + local config = { + name = "jdtls", + cmd = { + "jdtls", + "-data", + workspace_dir, + }, + root_dir = vim.fs.root(0, { ".git", "meta", "gradlew", "mvnw" }), + settings = { java = {} }, + init_options = { bundles = {} }, + } + require('jdtls').start_or_attach(config) + end +}) + +--[[ +function get_hl_groups() + for hl_name, hl in pairs(vim.api.nvim_get_hl(0, {})) do + print(hl_name) + end +end + +local function update_hl(group, tbl) + local old_hl = vim.api.nvim_get_hl_by_name(group, true) + local new_hl = vim.tbl_extend('force', old_hl, tbl) + vim.api.nvim_set_hl(0, group, new_hl) +end +]] |
