summaryrefslogtreecommitdiff
path: root/nixos/config/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/config/nvim')
-rw-r--r--nixos/config/nvim/init.lua201
1 files changed, 201 insertions, 0 deletions
diff --git a/nixos/config/nvim/init.lua b/nixos/config/nvim/init.lua
new file mode 100644
index 0000000..8e19474
--- /dev/null
+++ b/nixos/config/nvim/init.lua
@@ -0,0 +1,201 @@
+-- GLOBALS
+
+vim.g.mapleader = " "
+
+vim.o.number = true
+vim.o.relativenumber = false
+
+vim.o.undofile = true
+vim.o.ignorecase = true
+
+vim.o.expandtab = false
+vim.o.shiftwidth = 4
+vim.o.tabstop = 4
+vim.o.softtabstop = 4
+vim.o.smartindent = true
+vim.o.autoindent = true
+
+vim.o.signcolumn = "yes"
+vim.o.winborder = 'single'
+vim.o.showmode = true
+vim.o.guicursor = ""
+
+vim.o.swapfile = false
+
+vim.o.cursorline = true
+
+-- •⏎.·○◦
+--vim.o.list = true
+vim.o.listchars = "tab:🡪 ,trail:·,eol:⏎,space:·,multispace:·,lead:·,leadmultispace:·"
+
+vim.o.completeopt = "fuzzy,menuone,noselect"
+vim.diagnostic.config({ virtual_text = true })
+
+-- AUTOCOMPLETION
+
+vim.o.autocomplete = false
+vim.o.completeopt = 'menu,menuone,noselect'
+
+-- STATUSBAR
+
+vim.diagnostic.status()
+vim.lsp.status()
+
+-- 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
+
+vim.pack.add({
+ { src = "https://github.com/neovim/nvim-lspconfig" },
+ { src = "https://github.com/ibhagwan/fzf-lua" },
+ { src = "https://github.com/mfussenegger/nvim-jdtls" },
+ { src = "https://github.com/lewis6991/gitsigns.nvim" },
+ { src = "https://github.com/stevearc/oil.nvim" },
+ { src = "https://github.com/sphamba/smear-cursor.nvim" },
+ { src = "https://github.com/saghen/blink.cmp" },
+ { src = "https://github.com/saghen/blink.lib" },
+ { src = "https://github.com/folke/tokyonight.nvim" },
+ { src = "https://github.com/windwp/nvim-autopairs" }
+})
+
+vim.cmd [[colorscheme tokyonight-night]]
+
+
+require("blink.cmp").setup({ keymap = { preset = "enter" } })
+require('blink.cmp').build():wait(60000)
+require("nvim-autopairs").setup({})
+require("gitsigns").setup({})
+require("oil").setup({
+ default_file_explorer = true,
+ lsp_file_methods = {
+ enabled = true,
+ timeout_ms = 1000,
+ autosave_changes = true,
+ },
+ columns = {
+ "permissions",
+ "size",
+ },
+ float = {
+ max_width = 0.7,
+ max_height = 0.6,
+ border = vim.o.winborder,
+ },
+ buf_options = {
+ buflisted = false,
+ bufhidden = "hide",
+ },
+ view_options = {
+ show_hidden = true,
+ },
+})
+
+require("smear_cursor").setup({
+ 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,
+})
+
+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>]])
+map("n", "<leader><CR>", vim.lsp.buf.format)
+
+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/artix/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)
+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", "nil",
+ "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("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
+})