Useful Commands: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 36: Line 36:
  vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })
  vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })
</syntaxhighlight>
</syntaxhighlight>
=Running an LSP in Neovim=
==The GO LSP==
This was in .config/nvim/after/plugin/load_test_lsp.lua. I had to do lots of mapping because neovim is some old .9 version on ubuntu. Took longer to understand neovim than remember GO which I like again.
<syntaxhighlight lang="bash">
local client = vim.lsp.start_client {
    name = "educationlsp",
    cmd = { "/home/iwiseman/dev/projects/jsop-rpc/educationlsp/main" },
    on_attach = on_attach,
}
if not client then
  vim.notify "Hey, you didn't do the client thing"
  return
end
vim.keymap.set('n', 'gra', vim.lsp.buf.code_action)
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
vim.g.mapleader = " "
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { noremap = true, silent = true })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { noremap = true, silent = true })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { noremap = true, silent = true })
vim.keymap.set('n', '<leader>c', function()
    vim.api.nvim_command('close')
end, { noremap = true, silent = true })
vim.api.nvim_create_autocmd("FileType", {
  pattern = "markdown",
  callback = function()
      vim.lsp.buf_attach_client(0,client)
  end,
})
</syntaxhighlight> 
==The Typescript LSP==
Been working on a language server protocol and this was provided do run my Typescript version
<syntaxhighlight lang="bash">
vim.lsp.start {
    name = "Typescript LSP",
    cmd = {
      "npx"/, "ts-node",
      vim.fn.expand("~/dev/projects/blah/server.ts")
    },
    capabilities = vim.lsp.protocoal.make_client_capabilities()
}
</syntaxhighlight> 
To List the Lsp to see if running you can type :LspInfo. This didn't work because I had to install the plugin to do this. Thank to copilot this was easy. Here to demonstrate for other plugins.
==Install Vim-Plug==
The easy bit was this which simply puts something in the right place
<syntaxhighlight lang="bash">
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
</syntaxhighlight>
Next I needed a Plugin manager which copilot suggested vim-plug
==Add Plugin Config to init.vim==
Presumably you add a line for each plugin
<syntaxhighlight lang="bash">
call plug#begin('~/.local/share/nvim/plugged')
Plug 'neovim/nvim-lspconfig'
call plug#end()
</syntaxhighlight>
==Update Plugins==
In nvim we do ''':PlugInstall''' and hey presto :LspInfo<br>
[[File:NVIM LSP.png]]<br>

Latest revision as of 02:25, 31 March 2025

View Certificate Details

curl --insecure -vvI https://www.google.com 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'

List or Delete Files With Spaces

find DONTUSESLASH -type d -name '.vs' -print0 | xargs -0 ls -l
find DONTUSESLASH -type d -name '.vs' -print0 | xargs -0 rm -rf

Size of Directories

du -sh -- *  | sort -rh

List Size of node_modules

find . -name "node_modules" -type d -prune | xargs du -chs

Delete node_modules

find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

Testing for TLS v1.0 Support

nmap --script ssl-enum-ciphers -p 443 bibble.co.nz

Show Neovim Bindings

Here we go

:redir! > vim_keys.txt
:silent verbose map
:redir END

Leaders and Neovim

Leaders are keys you can press to activate a binding. In neovim you can set a leader key and then this is the key to activate a binding. E.g.

# Set leader to space
 vim.g.mapleader = " "
# Now space + e will open the diagnostic window. Copilot helped my out doing my LSP
 vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })

Running an LSP in Neovim

The GO LSP

This was in .config/nvim/after/plugin/load_test_lsp.lua. I had to do lots of mapping because neovim is some old .9 version on ubuntu. Took longer to understand neovim than remember GO which I like again.

local client = vim.lsp.start_client {
    name = "educationlsp",
    cmd = { "/home/iwiseman/dev/projects/jsop-rpc/educationlsp/main" },
    on_attach = on_attach,
}

if not client then
   vim.notify "Hey, you didn't do the client thing"
   return
end
vim.keymap.set('n', 'gra', vim.lsp.buf.code_action)
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })

vim.g.mapleader = " "
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { noremap = true, silent = true })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { noremap = true, silent = true })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { noremap = true, silent = true })

vim.keymap.set('n', '<leader>c', function()
    vim.api.nvim_command('close')
end, { noremap = true, silent = true })


vim.api.nvim_create_autocmd("FileType", {
   pattern = "markdown",
   callback = function()
      vim.lsp.buf_attach_client(0,client)
   end,
})

The Typescript LSP

Been working on a language server protocol and this was provided do run my Typescript version

vim.lsp.start {
    name = "Typescript LSP",
    cmd = {
       "npx"/, "ts-node",
       vim.fn.expand("~/dev/projects/blah/server.ts")
    },
    capabilities = vim.lsp.protocoal.make_client_capabilities()
}

To List the Lsp to see if running you can type :LspInfo. This didn't work because I had to install the plugin to do this. Thank to copilot this was easy. Here to demonstrate for other plugins.

Install Vim-Plug

The easy bit was this which simply puts something in the right place

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Next I needed a Plugin manager which copilot suggested vim-plug

Add Plugin Config to init.vim

Presumably you add a line for each plugin

call plug#begin('~/.local/share/nvim/plugged')
Plug 'neovim/nvim-lspconfig'
call plug#end()

Update Plugins

In nvim we do :PlugInstall and hey presto :LspInfo