diff options
| author | coast <coasteen@proton.me> | 2026-10-15 04:35:51 +0330 |
|---|---|---|
| committer | coast <coasteen@proton.me> | 2026-10-15 04:35:51 +0330 |
| commit | 4c20a256c370a65ecd34100a540ad9760e67f51d (patch) | |
| tree | b855be16d3b5cf7d1de15ae93f6a163e75194683 | |
| parent | 30ffc7cf394a9503771ea32b0a9e1fe41b155198 (diff) | |
| download | nix-4c20a256c370a65ecd34100a540ad9760e67f51d.tar.gz nix-4c20a256c370a65ecd34100a540ad9760e67f51d.tar.bz2 nix-4c20a256c370a65ecd34100a540ad9760e67f51d.tar.xz nix-4c20a256c370a65ecd34100a540ad9760e67f51d.tar.zst | |
new nvim changes
| -rw-r--r-- | configuration/default.nix | 1 | ||||
| -rw-r--r-- | home-configuration/config/niri/config.kdl | 2 | ||||
| -rw-r--r-- | home-configuration/config/nvim/after/plugin/netrw_tree_fix.lua | 58 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/init.lua | 3 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lazy-lock.json | 39 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lua/config.lua | 30 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lua/plugins/catppuccin/init.lua | 21 | ||||
| -rw-r--r-- | home-configuration/config/nvim/lua/plugins/conform/init.lua | 17 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lua/plugins/lazy/plugins.lua | 31 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lua/plugins/lsp/init.lua | 68 | ||||
| -rwxr-xr-x | home-configuration/config/nvim/lua/plugins/treesitter/init.lua | 311 | ||||
| -rw-r--r-- | home-configuration/default.nix | 2 |
12 files changed, 225 insertions, 358 deletions
diff --git a/configuration/default.nix b/configuration/default.nix index 789d780..4d936da 100644 --- a/configuration/default.nix +++ b/configuration/default.nix @@ -122,6 +122,7 @@ glibc.static unrar podman-compose + grub2 ]; nixpkgs.config.permittedInsecurePackages = [ "ventoy-1.1.17" ]; diff --git a/home-configuration/config/niri/config.kdl b/home-configuration/config/niri/config.kdl index 06aea17..9f436a7 100644 --- a/home-configuration/config/niri/config.kdl +++ b/home-configuration/config/niri/config.kdl @@ -1,5 +1,5 @@ spawn-sh-at-startup "XDG_DATA_DIRS=/etc/profiles/per-user/coast/share:/run/current-system/sw/share:$HOME/.nix-profile/share:$XDG_DATA_DIRS" -spawn-at-startup "qs" +spawn-at-startup "quickshell" spawn-at-startup "dbus-update-activation-environment" "--systemd" "WAYLAND_DISPLAY" "XDG_CURRENT_DESKTOP" input { diff --git a/home-configuration/config/nvim/after/plugin/netrw_tree_fix.lua b/home-configuration/config/nvim/after/plugin/netrw_tree_fix.lua new file mode 100644 index 0000000..af2030e --- /dev/null +++ b/home-configuration/config/nvim/after/plugin/netrw_tree_fix.lua @@ -0,0 +1,58 @@ +local orig = {} + +local function parse(line) + local prefix, name = line:match('^([| ]*)(.-)%s*$') + local _, depth = prefix:gsub('|', '') + return depth, name +end + +local function open_entry() + local buf = vim.api.nvim_get_current_buf() + local lnum = vim.fn.line('.') + local depth, name = parse(vim.fn.getline(lnum)) + + local function fallback() + local rhs = orig[buf] and orig[buf].rhs + if rhs and rhs ~= '' then + vim.api.nvim_feedkeys(vim.keycode(rhs), 'n', false) + end + end + + if name == '' or name:sub(-1) == '/' or depth == 0 then + return fallback() + end + + local parts, cur, top = {}, depth, nil + for l = lnum - 1, 1, -1 do + local d, n = parse(vim.fn.getline(l)) + if n ~= '' and d < cur and n:sub(-1) == '/' then + if d == 0 then + top = n + break + end + table.insert(parts, 1, n) + cur = d + end + end + + if not top or not top:match('^%a+://') then + return fallback() + end + + vim.cmd('edit ' .. vim.fn.fnameescape(top .. table.concat(parts) .. name)) +end + +local function install(buf) + local m = vim.fn.maparg('<CR>', 'n', false, true) + if m.callback then return end + orig[buf] = m + vim.keymap.set('n', '<CR>', open_entry, { buffer = buf, silent = true }) +end + +vim.api.nvim_create_autocmd({ 'BufEnter', 'CursorMoved' }, { + callback = function(a) + if vim.bo[a.buf].filetype == 'netrw' and vim.g.netrw_liststyle == 3 then + install(a.buf) + end + end, +}) diff --git a/home-configuration/config/nvim/init.lua b/home-configuration/config/nvim/init.lua index ab02259..144a842 100755 --- a/home-configuration/config/nvim/init.lua +++ b/home-configuration/config/nvim/init.lua @@ -1,6 +1,6 @@ require("plugins/lazy") require("plugins/lsp") -require("plugins/nvim-tree") +--require("plugins/nvim-tree") require("plugins/telescope") require("plugins/treesitter") require("config") @@ -8,3 +8,4 @@ require("plugins/render-markdown") --require("status_line").setup() require("plugins/lualine") require("plugins/catppuccin") +require("plugins/conform") diff --git a/home-configuration/config/nvim/lazy-lock.json b/home-configuration/config/nvim/lazy-lock.json index 3f016ea..4b9f19f 100755 --- a/home-configuration/config/nvim/lazy-lock.json +++ b/home-configuration/config/nvim/lazy-lock.json @@ -7,32 +7,35 @@ "cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" }, "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, "comfy-line-numbers.nvim": { "branch": "main", "commit": "9adedbaf1f410cdaacf4fb2ca8eb44f3d5f6d010" }, + "conform.nvim": { "branch": "master", "commit": "016802de402556da54c36bd7359b441266b01cdd" }, "fterm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "lsp_signature.nvim": { "branch": "master", "commit": "b7ace9ddb1640ce266012a45a672dfdaedfa5ec6" }, + "gentoo-syntax": { "branch": "master", "commit": "218a89826bf6cd09e95360ff9c621fbbe61552b8" }, + "haskell-vim": { "branch": "master", "commit": "f35d02204b4813d1dbe8b0e98cc39701a4b8e15e" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lsp_signature.nvim": { "branch": "master", "commit": "1997451c4c9956a1380d8bea4b0e33ebdf07976e" }, "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, - "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, - "mini.nvim": { "branch": "main", "commit": "d5e6f5b843f1d813d9c4bfb242b751dc5ab6f8ae" }, - "moonfly": { "branch": "master", "commit": "261664f92ed51cf0c077555b2d4b2530307eac17" }, - "none-ls-extras.nvim": { "branch": "main", "commit": "27681d797a26f1b4d6119296df42f5204c88a2dc" }, - "none-ls.nvim": { "branch": "main", "commit": "01f8e62ea11603e59ad9ff7afcfa94fd183f76d6" }, - "nvim": { "branch": "main", "commit": "0303a7208dba448c459767486a38a6ec05c4216b" }, - "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, - "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, - "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, - "nvim-numbertoggle": { "branch": "main", "commit": "c5c0d305aee8532b5515914a08396b9154394c55" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "mini.nvim": { "branch": "main", "commit": "8831fa150fa26492cfe135801fa498132f1491d2" }, + "moonfly": { "branch": "master", "commit": "2c883835f5b7b380a0a9e80695c420f7efebdfe4" }, + "netrw-icons.nvim": { "branch": "main", "commit": "3b2b1c006e962269c4c2d8c5f741053f86763eb9" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "9a8b8a9aeb43382e5aaf49b00b7cfb5d42d32118" }, + "none-ls.nvim": { "branch": "main", "commit": "c4b82bb63b13856ba4d6b971b7aad3bb38fc6fe2" }, + "nvim": { "branch": "main", "commit": "edefef779ab08ce1a4a404713e3012b0d202bd35" }, + "nvim-autopairs": { "branch": "master", "commit": "3172f40c16563db871a58f20d205c710ad782311" }, + "nvim-cmp": { "branch": "main", "commit": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac062d0d01c019c0dbdb798968f3e5d8b35c3853" }, + "nvim-numbertoggle": { "branch": "main", "commit": "704e098c7f056f0dae9407d8651edd3d183f3fff" }, "nvim-toggler": { "branch": "main", "commit": "467808600882fd6c9e33b9dbc4889b1b80cfd917" }, - "nvim-tree.lua": { "branch": "master", "commit": "07f541fcaa4a5ae019598240362449ab7e9812b3" }, - "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, + "nvim-treesitter": { "branch": "main", "commit": "ca581c3436fc2b236847f5b739ebc263739e5ca6" }, + "nvim-web-devicons": { "branch": "master", "commit": "ec309a0eaff6ea967e58c275996155ab5c16938d" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, - "render-markdown.nvim": { "branch": "main", "commit": "5adf0895310c1904e5abfaad40a2baad7fe44a07" }, + "render-markdown.nvim": { "branch": "main", "commit": "8e8795368391036643b622875a6da6a51bcd33f4" }, "telescope-undo.nvim": { "branch": "main", "commit": "928d0c2dc9606e01e2cc547196f48d2eaecf58e5" }, - "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "telescope.nvim": { "branch": "master", "commit": "40aedd8a68c78a656a10a8d62d80c54af59420fb" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "twilight.nvim": { "branch": "main", "commit": "664e752f4a219801265cc3fc18782b457b58c1e1" }, - "typst-preview.nvim": { "branch": "master", "commit": "325036ee145ca51d9efb145c09ac16bce3bc8b7d" }, + "typst-preview.nvim": { "branch": "master", "commit": "1c2e19486397be1c580b560fc50ee36abe329c46" }, "vim-closetag": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" }, "vim-vsnip": { "branch": "master", "commit": "9bcfabea653abdcdac584283b5097c3f8760abaa" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } diff --git a/home-configuration/config/nvim/lua/config.lua b/home-configuration/config/nvim/lua/config.lua index 9835875..2100a6c 100755 --- a/home-configuration/config/nvim/lua/config.lua +++ b/home-configuration/config/nvim/lua/config.lua @@ -4,6 +4,11 @@ local g = vim.g --filetypes vim.cmd("autocmd BufRead,BufNewFile *.m set filetype=objc") +vim.filetype.add({ + filename = { + ["cgitrc"] = "dosini", + }, +}) g.mapleader = " " @@ -21,8 +26,11 @@ opt.relativenumber = true opt.fillchars = "eob: " -g.loaded_netrw = 1 -g.loaded_netrwPlugin = 1 +--g.loaded_netrw = 1 +--g.loaded_netrwPlugin = 1 +vim.g.netrw_liststyle = 3 + +vim.cmd("let g:netrw_banner = 0") opt.termguicolors = true @@ -33,9 +41,9 @@ opt.shell = "/usr/bin/zsh" vim.lsp.handlers["textDocument/hover"] = function(err, result, ctx, config) - config = config or {} - config.border = "single" - return vim.lsp.handlers.hover(err, result, ctx, config) + config = config or {} + config.border = "single" + return vim.lsp.handlers.hover(err, result, ctx, config) end vim.diagnostic.config({ float = { border = "single" } }) @@ -82,8 +90,16 @@ map("n", "<leader>ff", builtin.find_files, {}) map("n", "<leader>fg", builtin.live_grep, {}) map("n", "<leader>fb", builtin.buffers, {}) map("n", "<leader>fh", builtin.help_tags, {}) -local treeapi = require("nvim-tree.api") -map("n", "<leader>e", treeapi.tree.toggle, {}) +--local treeapi = require("nvim-tree.api") +--map("n", "<leader>e", treeapi.tree.toggle, {}) map("n", "<A-i>", '<CMD>lua require("FTerm").toggle()<CR>') map("t", "<A-i>", '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>') + +map("n", "n", "nzzzv") +map("n", "n", "Nzzzv") +map("n", "<", "<gv", opts) +map("n", ">", ">gv", opts) +map("i", "<C-c>", "<ESC>") +map("n", "<C-c>", ":nohl<CR>", { desc = "Clear search hl", silent = true }) +map("n", "x", "_x", opts) diff --git a/home-configuration/config/nvim/lua/plugins/catppuccin/init.lua b/home-configuration/config/nvim/lua/plugins/catppuccin/init.lua index c497b4d..2137248 100755 --- a/home-configuration/config/nvim/lua/plugins/catppuccin/init.lua +++ b/home-configuration/config/nvim/lua/plugins/catppuccin/init.lua @@ -67,24 +67,3 @@ require("lualine").setup({ }, }, }) - -require("nvim-tree").setup({ - view = { - width = 30, - side = "left", - }, - renderer = { - highlight_git = true, - root_folder_modifier = ":~", - icons = { - show = { - file = true, - folder = true, - git = true, - }, - }, - }, - filters = { - dotfiles = false, - }, -}) diff --git a/home-configuration/config/nvim/lua/plugins/conform/init.lua b/home-configuration/config/nvim/lua/plugins/conform/init.lua new file mode 100644 index 0000000..374ed55 --- /dev/null +++ b/home-configuration/config/nvim/lua/plugins/conform/init.lua @@ -0,0 +1,17 @@ +require("conform").setup({ + formatters_by_ft = { + haskell = { "ormolu" }, + }, + formatters = { + ormolu = { + command = "ormolu", + args = { "--stdin-input-file", "$FILENAME" }, + stdin = true, + }, + }, + format_on_save = { timeout_ms = 2000, lsp_format = "never" }, +}) + +vim.keymap.set({ "n", "v" }, "<leader>f", function() + require("conform").format({ async = true, lsp_format = "never" }) +end) diff --git a/home-configuration/config/nvim/lua/plugins/lazy/plugins.lua b/home-configuration/config/nvim/lua/plugins/lazy/plugins.lua index 75b873a..4afee21 100755 --- a/home-configuration/config/nvim/lua/plugins/lazy/plugins.lua +++ b/home-configuration/config/nvim/lua/plugins/lazy/plugins.lua @@ -2,15 +2,27 @@ return { "andweeb/presence.nvim", "catppuccin/nvim", "neovim/nvim-lspconfig", + "gentoo/gentoo-syntax", "williamboman/mason.nvim", + "stevearc/conform.nvim", { - "nvim-telescope/telescope.nvim", - tag = "0.1.5", - dependencies = { "nvim-lua/plenary.nvim" }, + "neovimhaskell/haskell-vim", + ft = "haskell", + init = function() + vim.g.haskell_indent_disable = 0 + vim.g.haskell_indent_let = 2 + vim.g.haskell_indent_in = 1 + vim.g.haskell_indent_where = 2 + vim.g.haskell_indent_do = 2 + vim.g.haskell_indent_case = 2 + vim.g.haskell_indent_if = 2 + end, }, { - "nvim-tree/nvim-tree.lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, + "nvim-telescope/telescope.nvim", + --tag = "0.1.5", + branch = "master", + dependencies = { "nvim-lua/plenary.nvim" }, }, { "folke/todo-comments.nvim", @@ -126,4 +138,13 @@ return { lazy = false, priority = 1000, }, + { + "Fasamii/netrw-icons.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", -- or "echasnovski/mini.icons" + }, + config = function() + require("netrw-icons").setup() + end, + }, } diff --git a/home-configuration/config/nvim/lua/plugins/lsp/init.lua b/home-configuration/config/nvim/lua/plugins/lsp/init.lua index c5245d9..e21fba2 100755 --- a/home-configuration/config/nvim/lua/plugins/lsp/init.lua +++ b/home-configuration/config/nvim/lua/plugins/lsp/init.lua @@ -69,7 +69,7 @@ vim.api.nvim_create_autocmd('LspAttach', { }) end - local excluded_filetypes = { php = true, c = true, cpp = true } + local excluded_filetypes = { php = true, c = true, cpp = true, haskell = true, lhaskell = true } if not client:supports_method('textDocument/willSaveWaitUntil') and client:supports_method('textDocument/formatting') and not excluded_filetypes[vim.bo[buf].filetype] @@ -151,6 +151,21 @@ vim.lsp.config['luals'] = { }, } +vim.lsp.config['html'] = { + cmd = { 'vscode-html-language-server', '--stdio' }, + filetypes = { 'html' }, + root_markers = { 'package.json', '.git' }, + capabilities = caps, + init_options = { + provideFormatter = true, + }, + settings = { + html = { + validate = { scripts = true, styles = true }, + }, + }, +} + vim.lsp.config['cssls'] = { cmd = { 'vscode-css-language-server', '--stdio' }, filetypes = { 'css', 'scss', 'less' }, @@ -163,6 +178,46 @@ vim.lsp.config['cssls'] = { }, } +vim.lsp.config['eslint'] = { + cmd = { 'vscode-eslint-language-server', '--stdio' }, + filetypes = { + 'javascript', 'javascriptreact', 'javascript.jsx', + 'typescript', 'typescriptreact', 'typescript.tsx', + 'vue', 'svelte', 'astro', 'html', + }, + root_markers = { + 'eslint.config.js', 'eslint.config.mjs', 'eslint.config.cjs', + '.eslintrc.js', '.eslintrc.json', '.eslintrc', + 'package.json', '.git', + }, + capabilities = caps, + settings = { + validate = 'on', + packageManager = 'npm', + workingDirectory = { mode = 'auto' }, + }, +} + +vim.lsp.config['jsonls'] = { + cmd = { 'vscode-json-language-server', '--stdio' }, + filetypes = { 'json', 'jsonc' }, + root_markers = { 'package.json', '.git', 'config.jsonc' }, + capabilities = caps, + settings = { + json = { + validate = { enable = true }, + format = { enable = true }, + }, + }, +} + +vim.lsp.config['markdown'] = { + cmd = { 'vscode-markdown-language-server', '--stdio' }, + filetypes = { 'markdown' }, + root_markers = { '.git' }, + capabilities = caps, +} + vim.lsp.config['phpls'] = { cmd = { 'intelephense', '--stdio' }, filetypes = { 'php' }, @@ -248,21 +303,14 @@ vim.lsp.config['serve_d'] = { capabilities = caps, } -vim.lsp.config['jsonls'] = { - cmd = { 'vscode-json-languageserver', '--stdio' }, - filetypes = { 'json', 'jsonc' }, - root_markers = { 'package.json', '.git', 'config.jsonc' }, - capabilities = caps, -} - vim.lsp.config['hls'] = { cmd = { 'haskell-language-server-wrapper', '--lsp' }, filetypes = { 'haskell', 'lhaskell' }, - root_markers = { 'stack.yaml', 'cabal.project', 'package.yaml', '*.cabal', 'hie.yaml', '.git' }, + root_markers = { 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml', '.git' }, capabilities = caps, settings = { haskell = { - formattingProvider = 'fourmolu', + formattingProvider = 'ormolu', plugin = { semanticTokens = { globalOn = false } }, }, }, diff --git a/home-configuration/config/nvim/lua/plugins/treesitter/init.lua b/home-configuration/config/nvim/lua/plugins/treesitter/init.lua index ffc8b17..c50393b 100755 --- a/home-configuration/config/nvim/lua/plugins/treesitter/init.lua +++ b/home-configuration/config/nvim/lua/plugins/treesitter/init.lua @@ -1,305 +1,26 @@ -local lsp = require("lspconfig") -local cmp = require("cmp") +require("nvim-treesitter").setup() -vim.lsp.config('*', { - root_markers = { '.git' }, -}) - -vim.diagnostic.config({ - virtual_text = true, - severity_sort = true, - float = { - style = 'minimal', - border = 'rounded', - source = 'if_many', - header = '', - prefix = '', - }, - signs = { - text = { - [vim.diagnostic.severity.ERROR] = '✘', - [vim.diagnostic.severity.WARN] = '▲', - [vim.diagnostic.severity.HINT] = '⚑', - [vim.diagnostic.severity.INFO] = '»', - }, - }, -}) - -local orig = vim.lsp.util.open_floating_preview ----@diagnostic disable-next-line: duplicate-set-field -function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) - opts = opts or {} - opts.border = opts.border or 'rounded' - opts.max_width = opts.max_width or 80 - opts.max_height = opts.max_height or 24 - opts.wrap = opts.wrap ~= false - return orig(contents, syntax, opts, ...) -end - -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('my.lsp', {}), +vim.api.nvim_create_autocmd("FileType", { + pattern = "*", callback = function(args) - local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) - local buf = args.buf - local map = function(mode, lhs, rhs) vim.keymap.set(mode, lhs, rhs, { buffer = buf }) end - - map('n', 'K', vim.lsp.buf.hover) - map('n', 'gd', vim.lsp.buf.definition) - map('n', 'gD', vim.lsp.buf.declaration) - map('n', 'gi', vim.lsp.buf.implementation) - map('n', 'go', vim.lsp.buf.type_definition) - map('n', 'gr', vim.lsp.buf.references) - map('n', 'gs', vim.lsp.buf.signature_help) - map('n', 'gl', vim.diagnostic.open_float) - map('n', '<F2>', vim.lsp.buf.rename) - map({ 'n', 'x' }, '<F3>', function() vim.lsp.buf.format({ async = true }) end) - map('n', '<F4>', vim.lsp.buf.code_action) + local lang = vim.treesitter.language.get_lang(args.match) - if client:supports_method('textDocument/documentHighlight') then - local highlight_augroup = vim.api.nvim_create_augroup('my.lsp.highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) + if not lang or lang == "nix" then + return end - local excluded_filetypes = { php = true, c = true, cpp = true } - if not client:supports_method('textDocument/willSaveWaitUntil') - and client:supports_method('textDocument/formatting') - and not excluded_filetypes[vim.bo[buf].filetype] - then - vim.api.nvim_create_autocmd('BufWritePre', { - group = vim.api.nvim_create_augroup('my.lsp.format', { clear = false }), - buffer = buf, - callback = function() - vim.lsp.buf.format({ bufnr = buf, id = client.id, timeout_ms = 1000 }) - end, - }) + if vim.treesitter.language.add(lang) then + vim.treesitter.start(args.buf, lang) + return end - end, -}) -require("nvim-autopairs").setup({}) -require("lsp_signature").setup({ hint_enable = false }) + local available = require("nvim-treesitter").get_available() -cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - ["<C-b>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-e>"] = cmp.mapping.abort(), - ["<CR>"] = cmp.mapping.confirm({ select = true }), - ["<Tab>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() + if vim.tbl_contains(available, lang) then + require("nvim-treesitter").install({ lang }):wait(30000) + if vim.treesitter.language.add(lang) then + vim.treesitter.start(args.buf, lang) end - end, { "i", "s" }), - ["<S-Tab>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), - }), - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered() - }, - sources = cmp.config.sources({ - { name = "nvim_lsp", keyword_length = 1 }, - { name = "vsnip" }, - }, { - { name = "buffer", keyword_length = 1 }, - { name = "spell" }, - }), -}) - -local caps = require("cmp_nvim_lsp").default_capabilities() - -vim.lsp.config['luals'] = { - cmd = { 'lua-language-server' }, - filetypes = { 'lua' }, - root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' }, - capabilities = caps, - settings = { - Lua = { - runtime = { version = 'LuaJIT' }, - diagnostics = { globals = { 'vim' } }, - workspace = { - checkThirdParty = false, - library = vim.list_extend( - vim.api.nvim_get_runtime_file('', true), - { '/home/tony/repos/oxwm/templates' } - ), - }, - telemetry = { enable = false }, - }, - }, -} - -vim.lsp.config['cssls'] = { - cmd = { 'vscode-css-language-server', '--stdio' }, - filetypes = { 'css', 'scss', 'less' }, - root_markers = { 'package.json', '.git' }, - capabilities = caps, - settings = { - css = { validate = true }, - scss = { validate = true }, - less = { validate = true }, - }, -} - -vim.lsp.config['phpls'] = { - cmd = { 'intelephense', '--stdio' }, - filetypes = { 'php' }, - root_markers = { 'composer.json', '.git' }, - capabilities = caps, - settings = { - intelephense = { - files = { maxSize = 5000000 }, - }, - }, -} - -vim.lsp.config['ts_ls'] = { - cmd = { 'typescript-language-server', '--stdio' }, - filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }, - root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' }, - capabilities = caps, - settings = { - completions = { completeFunctionCalls = true }, - }, -} - -vim.lsp.config['zls'] = { - cmd = { 'zls' }, - filetypes = { 'zig', 'zir' }, - root_markers = { 'zls.json', 'build.zig', '.git' }, - capabilities = caps, - settings = { - zls = { - enable_build_on_save = true, - build_on_save_step = "install", - warn_style = false, - enable_snippets = true, - } - } -} - -vim.lsp.config['nil_ls'] = { - cmd = { 'nil' }, - filetypes = { 'nix' }, - root_markers = { 'flake.nix', 'default.nix', '.git' }, - capabilities = caps, - settings = { - ['nil'] = { - formatting = { - command = { "nixpkgs-fmt" } - } - } - } -} - -vim.lsp.config['rust_analyzer'] = { - cmd = { 'rust-analyzer' }, - filetypes = { 'rust' }, - root_markers = { 'Cargo.toml', 'rust-project.json', '.git' }, - capabilities = caps, - settings = { - ['rust-analyzer'] = { - cargo = { allFeatures = true }, - formatting = { command = { "rustfmt" } }, - }, - }, -} - -vim.lsp.config['clangd'] = { - cmd = { 'clangd', '--background-index', '--clang-tidy' }, - filetypes = { 'c', 'cpp', 'objc', 'objcpp' }, - root_markers = { 'compile_commands.json', '.clangd', 'configure.ac', 'Makefile', '.git' }, - capabilities = caps, -} - -vim.lsp.config['c3lsp'] = { - cmd = { 'c3-lsp' }, - filetypes = { 'c3' }, - root_markers = { 'project.json', '.git' }, - capabilities = caps, -} - -vim.lsp.config['serve_d'] = { - cmd = { 'serve-d' }, - filetypes = { 'd' }, - root_markers = { 'dub.sdl', 'dub.json', '.git' }, - capabilities = caps, -} - -vim.lsp.config['jsonls'] = { - cmd = { 'vscode-json-languageserver', '--stdio' }, - filetypes = { 'json', 'jsonc' }, - root_markers = { 'package.json', '.git', 'config.jsonc' }, - capabilities = caps, -} - -vim.lsp.config['hls'] = { - cmd = { 'haskell-language-server-wrapper', '--lsp' }, - filetypes = { 'haskell', 'lhaskell' }, - root_markers = { 'stack.yaml', 'cabal.project', 'package.yaml', '*.cabal', 'hie.yaml', '.git' }, - capabilities = caps, - settings = { - haskell = { - formattingProvider = 'fourmolu', - plugin = { semanticTokens = { globalOn = false } }, - }, - }, -} - -vim.lsp.config['gopls'] = { - cmd = { 'gopls' }, - filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, - root_markers = { 'go.mod', 'go.work', '.git' }, - capabilities = caps, - settings = { - gopls = { - analyses = { unusedparams = false, ST1003 = false, ST1000 = false }, - staticcheck = true, - }, - }, -} - -vim.lsp.config['templ'] = { - cmd = { 'templ', 'lsp' }, - filetypes = { 'templ' }, - root_markers = { 'go.mod', '.git' }, - capabilities = caps, -} - -vim.filetype.add({ - extension = { - h = 'c', - c3 = 'c3', - d = 'd', - templ = 'templ', - }, + end + end, }) - ----@diagnostic disable-next-line: invisible -for name, _ in pairs(vim.lsp.config._configs) do - if name ~= '*' then - vim.lsp.enable(name) - end -end diff --git a/home-configuration/default.nix b/home-configuration/default.nix index 9dd9a84..1cc7efb 100644 --- a/home-configuration/default.nix +++ b/home-configuration/default.nix @@ -145,6 +145,8 @@ in pkgs.playerctl pkgs.file pkgs.fooyin + pkgs.syslinux + pkgs.tigervnc inputs.qml-niri.packages.${pkgs.system}.quickshell ]; |
