-- neovim config file build by vincent.delft@gmail.com -- Bootstrap Lazy.nvim 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", lazypath, }) end vim.opt.rtp:prepend(lazypath) -- Set leader key vim.g.mapleader = " " vim.g.maplocalleader = " " -- Basic Neovim settings vim.opt.number = true -- Show line numbers vim.opt.tabstop = 4 -- 4 spaces for tabs vim.opt.shiftwidth = 4 -- 4 spaces for indentation vim.opt.expandtab = true -- Convert tabs to spaces vim.opt.smartindent = true -- Smart indentation vim.opt.termguicolors = true -- Enable true colors vim.opt.signcolumn = "yes" -- show left column -- Show relative line numbers for all other lines vim.opt.relativenumber = true -- Set colorscheme to ron -- To list all colorscheme, just type :colorscheme vim.cmd([[colorscheme ron]]) -- Lazy.nvim setup require("lazy").setup({ { "neovim/nvim-lspconfig" }, { "hrsh7th/nvim-cmp" }, { "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/cmp-buffer" }, { "hrsh7th/cmp-path" }, { "hrsh7th/cmp-nvim-lsp-signature-help" }, { "L3MON4D3/LuaSnip" }, { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", config = function() require("nvim-treesitter.configs").setup { -- List of languages to install parsers for ensure_installed = { "bash", "html", "css", "javascript", "python", "lua" }, -- Automatically install missing parsers when entering buffer auto_install = true, highlight = { enable = true, -- Enables syntax highlighting additional_vim_regex_highlighting = false, }, indent = { enable = true, -- Enables Tree-sitter based indentation }, } end, }, { "pablos123/shellcheck.nvim", config = function () require 'shellcheck-nvim'.setup {} end }, { "windwp/nvim-ts-autotag", config = function() require("nvim-ts-autotag").setup({ opts = { enable_close = true, -- auto-close tags enable_rename = true, -- auto-rename paired tags enable_close_on_slash = false, -- optionally, add per_filetype overrides here }, }) end, }, { "uga-rosa/ccc.nvim", config = function() require("ccc").setup({ -- optional settings here highlighter = { auto_enable = true, -- highlight color codes automatically -- lsp = true, -- enable LSP-based detection }, }) end, }, { "hrsh7th/cmp-emoji" }, -- to enter emoticons, type : }, { install = { colorscheme = { "ron", "habamax" } }, }) -- LSP setup local lspconfig = require("lspconfig") -- Python LSP lspconfig.pylsp.setup { settings = { pylsp = { plugins = { -- pycodestyle = { enabled = true, ignore = { "E501" }, }, pycodestyle = { enabled = false }, pylint = { enabled = true, args = { "--disable=C0301,C0209" }, -- line too long, use format }, jedi_completion = { enabled = true }, }, }, }, } -- Autocompletion setup local cmp = require("cmp") cmp.setup({ snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, { name = "nvim_lsp_signature_help" }, { name = "emoji" }, }), }) -- Treesitter for syntax highlighting require("nvim-treesitter.configs").setup({ ensure_installed = { "python", "bash" }, highlight = { enable = true }, indent = { enable = true }, }) -- Basic keybindings vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Show diagnostics" }) vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Diagnostics list" }) vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover documentation" }) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "Code action" }) -- Diagnostic in statusline for current line _G.DiagnosticStatus = function() local diag = vim.diagnostic.get(0, { lnum = vim.fn.line('.') - 1 }) if vim.tbl_isempty(diag) then return '' end -- Find most severe message on the line table.sort(diag, function(a, b) return a.severity < b.severity end) local d = diag[1] -- Severity icons local severity_icons = { [vim.diagnostic.severity.ERROR] = "⛔", [vim.diagnostic.severity.WARN] = "⚠️", [vim.diagnostic.severity.INFO] = "ℹ️", [vim.diagnostic.severity.HINT] = "💡", } local icon = severity_icons[d.severity] or "" local msg = d.message:gsub("\n", " ") return string.format(" %s %s ", icon, msg) end vim.o.statusline = "%f %h%m%r%=%{v:lua.DiagnosticStatus()} %l:%c" -- tips: -- to yank lines in the clipboard: doas pkg install xclip -- 1st option) in V mode, select lines, then type "+y You can ctrl-v -- 1st option) in V mode, select lines, then type "*y You can middle click -- 2nd option) type :.,.+5yank * release by middle click -- 2nd option) type :.,.+5yank + release by ctrl-v --